File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -455,7 +455,7 @@ class GraphViewNode {
455455 switch ( event ) {
456456 case 'updatePosition' : {
457457 nodeView . on ( 'element:pointerup' , ( ) => {
458- var newPos = this . _graphView . getWindowToGraphPosition ( nodeView . getBBox ( ) ) ;
458+ var newPos = this . _graphView . getWindowToGraphPosition ( nodeView . getBBox ( ) , false ) ;
459459 callback ( this . nodeData . id , newPos ) ;
460460 } ) ;
461461 break ;
Original file line number Diff line number Diff line change @@ -157,13 +157,17 @@ class GraphView extends JointGraph {
157157 }
158158 }
159159
160- getWindowToGraphPosition ( pos ) {
160+ getWindowToGraphPosition ( pos , usePaperPosition = true ) {
161161 const scale = this . _paper . scale ( ) . sx ;
162162 const translate = this . _paper . translate ( ) ;
163- const boundingClientRect = this . _paper . el . getBoundingClientRect ( ) ;
163+ if ( usePaperPosition ) {
164+ const paperPosition = this . _paper . el . getBoundingClientRect ( ) ;
165+ pos . x -= paperPosition . x ;
166+ pos . y -= paperPosition . y ;
167+ }
164168 return new Vec2 (
165- ( - translate . tx / scale ) + ( ( pos . x - boundingClientRect . x ) / scale ) ,
166- ( - translate . ty / scale ) + ( ( pos . y - boundingClientRect . y ) / scale )
169+ ( - translate . tx / scale ) + ( pos . x / scale ) ,
170+ ( - translate . ty / scale ) + ( pos . y / scale )
167171 ) ;
168172 }
169173
You can’t perform that action at this time.
0 commit comments