Skip to content

Commit 27fa2f9

Browse files
committed
add options allowTransform default true. when set false, set ghostEl position by top and left
1 parent bb197d8 commit 27fa2f9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Sortable.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@
224224
forceFallback: false,
225225
fallbackClass: 'sortable-fallback',
226226
fallbackOnBody: false,
227-
scrollContainer: null
227+
scrollContainer: null,
228+
allowTransform:true
228229
};
229230

230231

@@ -494,17 +495,24 @@
494495
this._appendGhost();
495496

496497
var touch = evt.touches ? evt.touches[0] : evt,
498+
originalTouchEvt = touchEvt || tapEvt,
497499
dx = touch.clientX - tapEvt.clientX,
498500
dy = touch.clientY - tapEvt.clientY,
499501
translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
500502

501503
moved = true;
502504
touchEvt = touch;
503-
504-
_css(ghostEl, 'webkitTransform', translate3d);
505-
_css(ghostEl, 'mozTransform', translate3d);
506-
_css(ghostEl, 'msTransform', translate3d);
507-
_css(ghostEl, 'transform', translate3d);
505+
if(opts.allowTransform){
506+
_css(ghostEl, 'webkitTransform', translate3d);
507+
_css(ghostEl, 'mozTransform', translate3d);
508+
_css(ghostEl, 'msTransform', translate3d);
509+
_css(ghostEl, 'transform', translate3d);
510+
}else{
511+
var top = parseInt(_css(ghostEl,"top"));
512+
var left = parseInt(_css(ghostEl,"left"));
513+
_css(ghostEl, 'top', top + touch.clientY - originalTouchEvt.clientY);
514+
_css(ghostEl, 'left', left + touch.clientX - originalTouchEvt.clientX);
515+
}
508516

509517
evt.preventDefault();
510518
}

0 commit comments

Comments
 (0)