You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/**
* mui gesture drag[start|left|right|up|down|end]
* @param {type} $
* @param {type} name
* @returns {undefined}
*/
( function ( $ , name ) {
var handle = function ( event , touch ) {
var session = $ . gestures . session ;
switch ( event . type ) {
case $ . EVENT _START :
break ;
case $ . EVENT _MOVE :
if ( ! touch . direction || ! session . target ) {
return ;
}
//修正direction,可在session期间自行锁定拖拽方向, 方便开发scroll类不同方向拖拽插件嵌套
if ( session . lockDirection && session . startDirection ) {
if ( session . startDirection && session . startDirection !== touch . direction ) {
if ( session . startDirection === 'up' || session . startDirection === 'down' ) {
touch . direction = touch . deltaY < 0 ? 'up' : 'down' ;
} else {
touch . direction = touch . deltaX < 0 ? 'left' : 'right' ;
}
}
}
if ( ! session . drag ) {
session . drag = true ;
$ . trigger ( session . target , name + 'start' , touch ) ;
}
$ . trigger ( session . target , name , touch ) ;
$ . trigger ( session . target , name + touch . direction , touch ) ;
break ;
case $ . EVENT _END :
case $ . EVENT _CANCEL :
if ( session . drag && touch . isFinal ) {
$ . trigger ( session . target , name + 'end' , touch ) ;
}
break ;
}
} ;
/**
* mui gesture drag
*/
$ . addGesture ( {
name : name ,
index : 20 ,
handle : handle ,
options : {
fingers : 1
}
} ) ;
} ) ( mui , 'drag' ) ;