<script type="text/javascript">
var ul = document.querySelector('ul'); var li = ul.querySelectorAll('li'); ul.style.width = li[0].offsetWidth * li.length + 'px'; var startX; function start(e) { startX = e.changedTouches[0].pageX; } function move(e) { e.preventDefault(); var moveX = e.changedTouches[0].pageX; var moveDistance = moveX - startX; ul.style.left = moveDistance + 'px' } ul.addEventListener('touchstart',start); ul.addEventListener('touchend',move);</script>
首页我点击ul滑动,滑动的一定的距离松开后, 再start时候,left的值就为0了,start 并不没有设置 left 的值,为么会变呀????
相关分类