Skip to content

Commit

Permalink
add options allowTransform default true. when set false, set ghostEl …
Browse files Browse the repository at this point in the history
…position by top and left
  • Loading branch information
why520crazy committed Jun 21, 2016
1 parent bb197d8 commit 27fa2f9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
forceFallback: false,
fallbackClass: 'sortable-fallback',
fallbackOnBody: false,
scrollContainer: null
scrollContainer: null,
allowTransform:true
};


Expand Down Expand Up @@ -494,17 +495,24 @@
this._appendGhost();

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

moved = true;
touchEvt = touch;

_css(ghostEl, 'webkitTransform', translate3d);
_css(ghostEl, 'mozTransform', translate3d);
_css(ghostEl, 'msTransform', translate3d);
_css(ghostEl, 'transform', translate3d);
if(opts.allowTransform){
_css(ghostEl, 'webkitTransform', translate3d);
_css(ghostEl, 'mozTransform', translate3d);
_css(ghostEl, 'msTransform', translate3d);
_css(ghostEl, 'transform', translate3d);
}else{
var top = parseInt(_css(ghostEl,"top"));
var left = parseInt(_css(ghostEl,"left"));
_css(ghostEl, 'top', top + touch.clientY - originalTouchEvt.clientY);
_css(ghostEl, 'left', left + touch.clientX - originalTouchEvt.clientX);
}

evt.preventDefault();
}
Expand Down

0 comments on commit 27fa2f9

Please sign in to comment.