我正在使用下面的代码向左滑动&正确的移动jQuery中的列表元素,我需要确定一个li当前对齐swiped ..代码正在工作 罚款我只需要识别被刷过的锂即可。需要识别中心李ul
<script>
$(function() {
var item = $('.pan li');
var itemWidth = item.width();
var itemLenght = item.length;
var scrollerWidth = itemWidth * itemLenght;
scrollLimt = itemWidth;
item.click(function(){
item.removeClass('active');
$(this).addClass('active');
});
var position = 0;
function next() {
position -= scrollLimt;
if (position <= -scrollerWidth)
position = 0;
update();
}
function prev() {
position += scrollLimt;
if (position > 0)
position = 0;
update();
}
function update() {
var pan = document.getElementById("pan");
pan.style.OTransform = "translateX(" + position + "px)";
pan.style.MozTransform = "translateX(" + position + "px)";
pan.style.WebkitTransform = "translateX(" + position + "px)";
}
$('#pan').bind("swipeleft", next);
$('#pan').bind("swiperight", prev);
$("img").bind("dragstart", function(ev) { ev.preventDefault(); });
});
</script>
jQuery的发现者......貌似有些SO jQuery的履带:) – gaurav 2013-02-19 10:41:24