Skip to content

Commit

Permalink
Update the touch event handlers in the renderer for dragging nodes to…
Browse files Browse the repository at this point in the history
… use `nodes.silentShift()`

Ref #1881
  • Loading branch information
maxkfranz committed Jul 9, 2018
1 parent 19aaba9 commit 84c870d
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/extensions/renderer/base/load-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,6 @@ BRp.load = function(){

var tcol = cy.collection( toTrigger );

// TODO apply same change to touch
//
( tcol
.silentShift( totalShift )
.emit('position drag')
Expand Down Expand Up @@ -1636,28 +1634,22 @@ BRp.load = function(){
addNodesToDrag( cy.collection( draggedEles ), { inDragLayer: true } );
}

for( var k = 0; k < draggedEles.length; k++ ){
var draggedEle = draggedEles[ k ];
r.dragData.didDrag = true;

if( r.nodeIsDraggable( draggedEle ) && draggedEle.grabbed() ){
r.dragData.didDrag = true;
var dPos = draggedEle.position();
var totalShift = { x: 0, y: 0 };

if( is.number( disp[0] ) && is.number( disp[1] ) ){
dPos.x += disp[0];
dPos.y += disp[1];
}

if( justStartedDrag ){
r.redrawHint( 'eles', true );
if( is.number( disp[0] ) && is.number( disp[1] ) ){
totalShift.x += disp[0];
totalShift.y += disp[1];

var dragDelta = r.touchData.dragDelta;
if( justStartedDrag ){
r.redrawHint( 'eles', true );

if( dragDelta && is.number( dragDelta[0] ) && is.number( dragDelta[1] ) ){
dPos.x += dragDelta[0];
dPos.y += dragDelta[1];
}
var dragDelta = r.touchData.dragDelta;

if( dragDelta && is.number( dragDelta[0] ) && is.number( dragDelta[1] ) ){
totalShift.x += dragDelta[0];
totalShift.y += dragDelta[1];
}
}
}
Expand All @@ -1669,6 +1661,11 @@ BRp.load = function(){

r.hoverData.draggingEles = true;

( tcol
.silentShift( totalShift )
.emit('position drag')
);

r.redrawHint( 'drag', true );

if(
Expand Down

0 comments on commit 84c870d

Please sign in to comment.