File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 6666
6767 conf = $ . extend ( { x : true , y : true , drag : true } , conf ) ;
6868
69- doc = doc || $ ( document ) . bind ( "mousedown mouseup" , function ( e ) {
69+ doc = doc || $ ( document ) . bind ( "mousedown mouseup touchstart touchend " , function ( e ) {
7070
7171 var el = $ ( e . target ) ;
7272
7373 // start
74- if ( e . type == "mousedown" && el . data ( "drag" ) ) {
75-
74+ if ( ( e . type == "mousedown" || e . type == "touchstart" ) && el . data ( "drag" ) ) {
75+ // touchstart/touchmove use e.orginalEvent.pageX/Y instead of e.pageX/Y
7676 var offset = el . position ( ) ,
77- x0 = e . pageX - offset . left ,
78- y0 = e . pageY - offset . top ,
77+ x0 = ( e . pageX || e . originalEvent . pageX ) - offset . left ,
78+ y0 = ( e . pageY || e . originalEvent . pageY ) - offset . top ,
7979 start = true ;
80-
81- doc . bind ( "mousemove.drag" , function ( e ) {
82- var x = e . pageX - x0 ,
83- y = e . pageY - y0 ,
80+
81+ doc . bind ( "mousemove.drag touchmove.drag " , function ( e ) {
82+ var x = ( e . pageX || e . originalEvent . pageX ) - x0 ,
83+ y = ( e . pageY || e . originalEvent . pageY ) - y0 ,
8484 props = { } ;
8585
8686 if ( conf . x ) { props . left = x ; }
104104 draggable . trigger ( "dragEnd" ) ;
105105 }
106106 } finally {
107- doc . unbind ( "mousemove.drag" ) ;
107+ doc . unbind ( "mousemove.drag touchmove.drag " ) ;
108108 draggable = null ;
109109 }
110110 }
You can’t perform that action at this time.
0 commit comments