<div class="mui-content">
<div class="mui-scroll-wrapper">
<div class="mui-scroll">
<div class="mui-slider">
<div class="mui-slider-group mui-slider-loop">
<div class="mui-slider-item mui-slider-item-duplicate">
<img src="../images/cache/banner/003.jpg"/>
</div>
<div class="mui-slider-item">
<img src="../images/cache/banner/001.jpg"/>
</div>
<div class="mui-slider-item">
<img src="../images/cache/banner/002.jpg"/>
</div>
<div class="mui-slider-item">
<img src="../images/cache/banner/003.jpg"/>
</div>
<div class="mui-slider-item mui-slider-item-duplicate">
<img src="../images/cache/banner/001.jpg"/>
</div>
</div>
</div>
</div>
</div>
</div>
在scroll(区域滚动)中使用slide(轮播组件)时, document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
e.preventDefault();
var x = e.detail.x;
var y = e.detail.y;
console.log(x);
console.log(y);
});会被slide(轮播组件)触发,导致var y = e.detail.y; console.log(y);值为0,从而无法在滚动到一定位置时决定定位选择栏。
- 发布:2018-03-03 23:51
- 更新:2018-03-05 11:52
- 阅读:1774
在scroll(区域滚动)中使用slide(轮播组件)时,slide(轮播组件)会触发scroll(区域滚动)的坐标事件
w***@163.com (作者)
//滚动
var scroll = mui('.mui-scroll-wrapper').scroll();
var bd = mui('body')[0].offsetHeight / 2;
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
var y = -scroll.y;
if (y > bd) {
mui('div.release')[0].setAttribute('class', 'release active');
mui('div.release')[0].firstChild.setAttribute('src', '../images/active/photograph_active.svg');
} else {
mui('div.release')[0].setAttribute('class', 'release');
mui('div.release')[0].firstChild.setAttribute('src', '../images/active/photograph.svg');
}
});