|
楼主 |
发表于 2015-9-29 17:42:42
|
显示全部楼层
怎么实现呢,我试试了还是会显示原来的行上,不是空白区。另外,因为是同一个ID,所以,显示和隐藏就会有冲突,第二个就不显示了。。。Model.prototype.swipeDelete = function() {
var briefMsgContentID = this.getIDByXID('briefMsgContent');
var swipeAreaSize = 100;
var dx;
var deleteRowDivId = this.getIDByXID('deleteRowDiv');
touch.on('#' + briefMsgContentID, 'touchstart', function(ev) {
ev.preventDefault();
var $swipNode = $('#' + briefMsgContentID + " li").has(ev.target);
dx = parseInt($swipNode.attr('swipeX') || "0");
});
touch.on('#' + briefMsgContentID, 'drag', function(ev) {
var $swipNode = $('#' + briefMsgContentID + " 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('#' + briefMsgContentID, 'dragend', function(ev) {
var $swipNode = $('#' + briefMsgContentID + " li").has(ev.target);
if (ev.direction === "left") {
$('#' + deleteRowDivId).show();
$swipNode.css({
'transform' : 'translate3d(-' + swipeAreaSize + 'px,0,0)'
});
$swipNode.addClass('x-swipe-out');
dx = swipeAreaSize * -1;
} else if (ev.direction === "right") {
$('#' + deleteRowDivId).hide();
$swipNode.removeClass('x-swipe-out');
$swipNode.css({
'transform' : 'translate3d(0,0,0)'
});
dx = 0;
}
$swipNode.attr('swipeX', dx);
});
};
|
-
|