|
楼主 |
发表于 2016-7-25 22:13:41
|
显示全部楼层
Model.prototype.swipeDelete = function(){
var jobContentID = this.getIDByXID('content3');
var swipeAreaSize = 100;
var dx;
touch.on('#' + jobContentID, 'touchstart', function(ev){
//ev.preventDefault();
var $swipNode = $('#' + jobContentID + " li").has(ev.target);
dx = parseInt($swipNode.attr('swipeX') || "0");
});
touch.on('#'+ jobContentID, 'drag', function(ev){
var $swipNode = $('#' + jobContentID + " li").has(ev.target);
if(ev.direction === "left" || ev.direction === "right"){
dx = dx || 0;
var offx = dx + ev.x;
if(offx < swipeAreaSize*-1){
offx = swipeAreaSize*-1;
}
if(offx > 0){
offx = 0;
}
if(ev.direction === "right" && $swipNode.hasClass('x-swipe-out')){
$swipNode.css({'transform':'translate3d('+offx+'px,0,0)'});
}else if(ev.direction === "left" && (!$swipNode.hasClass('x-swipe-out'))){
$swipNode.css({'transform':'translate3d('+offx+'px,0,0)'});
}
}
});
touch.on('#'+ jobContentID, 'dragend', function(ev){
var $swipNode = $('#' + jobContentID + " li").has(ev.target);
if(ev.direction === "left"){
$swipNode.css({'transform':'translate3d(-'+swipeAreaSize+'px,0,0)'});
$swipNode.addClass('x-swipe-out');
dx = swipeAreaSize*-1;
}else if(ev.direction === "right"){
$swipNode.removeClass('x-swipe-out');
$swipNode.css({'transform':'translate3d(0,0,0)'});
dx = 0;
}
$swipNode.attr('swipeX',dx);
});
};
我不知道错在哪里?该导入的touch.js文件我也导入了。但是就是实现不了滑动删除的功能。
|
-
我的布局结构,和系统的很类似
-
导入js文件
-
加载函数
|