var scroll = document.querySelector('.scroll');
var outerScroller = document.querySelector('.outerScroller');
var touchStart = 0;
var touchDis = 0;
externalScroller.addEventListener('touchstart', function(event) {
var touch = event.targetTouches[0];
// 將元素放在手指的位置
touchStart = touch.pageY;
console.log(touchStart);
},假);
externalScroller.addEventListener('touchmove', function(event) {
var touch = event.targetTouches[0];
console.log(touch.pageY 'px');
scroll.style.top =scroll.offsetTop touch.pageY-touchStart 'px';
console.log(scroll.style.top);
touchStart = touch.pageY;
touchThis = touch.pageY-touchStart;
},假);
externalScroller.addEventListener('touchend', function(event) {
touchStart = 0;
var top = scroll.offsetTop;
console.log(上);
if(top>70)refresh();
if(上>0){
var time = setInterval(function(){
scroll.style.top =scroll.offsetTop -2 'px';
if(scroll.offsetTop
},1)
}
},假);
函數刷新(){
for(var i = 10;i>0;i--)
{
var node = document.createElement("li");
node.innerHTML = "我是新的";
scroll.insertBefore(node,scroll.firstChild);
}
}
>腳本