Skip to content

Commit

Permalink
selection region box drawing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Jan 24, 2024
1 parent fd18f56 commit 02bb7b1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/GraphRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ export class GraphRenderer {
if(event.shiftKey){
//drag selection region handler
GraphRenderer.isDraggingSelectionRegion = true
GraphRenderer.selectionRegionStart = {x:event.pageX,y:event.pageY}
GraphRenderer.selectionRegionStart = {x:GraphRenderer.SCREEN_TO_GRAPH_POSITION_X(),y:GraphRenderer.SCREEN_TO_GRAPH_POSITION_Y()}
$('#selectionRectangle').show()
$('#selectionRectangle').css({'left':GraphRenderer.selectionRegionStart.x+'px','top':GraphRenderer.selectionRegionStart.y+'px'})
console.log('started draggin selection region', GraphRenderer.selectionRegionStart)
Expand Down Expand Up @@ -771,8 +771,13 @@ export class GraphRenderer {
}

} else if(GraphRenderer.isDraggingSelectionRegion){
GraphRenderer.selectionRegionEnd = {x:GraphRenderer.dragCurrentPosition.x, y:GraphRenderer.dragCurrentPosition.y}
$('#selectionRectangle').css({'right':GraphRenderer.selectionRegionEnd.x+'px','bottom':GraphRenderer.selectionRegionEnd.y+'px'})
GraphRenderer.selectionRegionEnd = {x:GraphRenderer.SCREEN_TO_GRAPH_POSITION_X(), y:this.SCREEN_TO_GRAPH_POSITION_Y()}
const containerWidth = $('#logicalGraphD3Div').width()
const containerHeight = $('#logicalGraphD3Div').height()
const selectionBottomOffset = containerHeight - GraphRenderer.selectionRegionEnd.y
const selectionRightOffset = containerWidth - GraphRenderer.selectionRegionEnd.x

$('#selectionRectangle').css({'right':selectionRightOffset+'px','bottom':selectionBottomOffset+'px'})
console.log(GraphRenderer.isDraggingSelectionRegion,GraphRenderer.selectionRegionEnd,'dragging the selction region')
}else{
// move background
Expand Down

0 comments on commit 02bb7b1

Please sign in to comment.