在下面的代码中,我添加了三个注释来解释问题所在。简而言之:我想知道e.preventDefault();
当它已经设置时如何禁用?
var startY;
myScroll = new iScroll(DOMElement, {
snap: 'li',
bounce: false,
bounceLock: false,
momentum: false,
hScrollbar: false,
vScrollbar: false,
hScroll: true,
vScroll: false,
wheelAction: 'scroll',
onBeforeScrollStart: function(e){
startY = e.pageY;
// By default it's advisable to disable browser's scroll
e.preventDefault();
},
onScrollStart: function(){ },
onScrollMove: function(e){
// But here I want to enable browser's functionality if user
// explicitly demands this (i.e. tries to scroll vertically)
if(startY >= e.pageY+70 || startY <= e.pageY-70){
console.log('test');
//alert('test');
console.log(e);
// However, I don't know how to restore this functionality
// Touch device detects 'test' alert correctly and this is
// where I'm stuck.
}
},
onScrollEnd: function(){ },
onRefresh: function(){ },
onDestroy: function(){ },
});
任何帮助,将不胜感激!