【发布时间】:2015-08-04 17:29:08
【问题描述】:
看起来iscroll 已正确启动。我将回调附加到scrollEnd 事件,每次垂直滚动尝试都会得到 p>
this.x: 0
this.y: 0
thisdirectionX: 0
thisdirectionY: 0
出于测试目的,我设置了this.scroller.scrollTo(0,300); 以查看脚本是否正常工作,并且确实如此。一旦我尝试进一步滚动,滚动条就会恢复到其初始位置,并以平滑的效果完成。
我使用 browserify 在一个主干.js 应用程序中加载模块。
var Iscroll = require('iscroll');
//for testing purposes to ensure that the scroller is loaded when the DOM is ready I do the following:
setTimeout(function(){
this.scroller = new Iscroll('#scroller', {
scrollX: false,
scrollY: true,
click:true, // open click event
scrollbars: false,
useTransform: true,
useTransition: true,
probeType:3,
mouseWheel:true,
bindToWrapper: true
});
this.scroller.scrollTo(0,300);
this.scroller.on('scrollEnd', function () {
console.log('x: ' + this.x);
console.log('y: ' + this.y);
console.log('d.x: ' + this.directionX);
console.log('d.y: ' + this.directionY);
console.log('scroll end');
});
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
}, 3000);
一旦我尝试滚动,我总是会触发一个 'touchstart' 事件,并且在配置 iscroll 脚本时,this.x 和 this.y 总是为 0。
HTML 很复杂,但我也在没有它的情况下进行了测试,我什至禁用了 css 文件但无济于事。
<div id="scroller">
<ul class="c-list" style="transition-timing-function: cubic-bezier(0.1, 0.57, 0.1, 1); transition-duration: 0ms; transform: translate(0px, 0px) translateZ(0px);">
<li>...</li>
<li>...</li>
<li>...</li>
...
</ul>
</div>
有人有想法吗?
【问题讨论】:
标签: backbone.js iscroll