我有一个支持滑动手势的画廊。通过向左/向右滑动,用户可以浏览图库。我需要限制滑动div的位置,这样它就不会偏离轨道,也就是说,一旦你到达页面,显然所有的图像都在右边,所以我不想让用户向左滑动(到空白区域)。
我试着使用“大于”,但它不起作用。
var theWidth = $(window).width();
function processingRoutine() {
var swipedElement = document.getElementById(triggerElementID);
if ( swipeDirection == 'left' ) {
$(".frame").animate({marginLeft: '-='+theWidth});
} else if ( swipeDirection == 'right' ) {
$(".frame").animate({marginLeft: '+='+theWidth});
if ( parseInt($(".frame").css("margin-left")) > 1 ) {
$(".frame").animate({marginLeft: "0px"});
}
}
}你可以在这里查看整个源代码:http://joinersart.co.uk/mtest
发布于 2012-09-21 05:08:11
更改:
$(".frame").animate({margin-left: "0px"});至:
$(".frame").animate({marginLeft: "0px"});https://stackoverflow.com/questions/12520613
复制相似问题