嗯,就是客户这边有个需求就是仿JD啊苏宁的网页端,用户滑动滚动条的情况下地址栏会缩起来,滚动到顶部的时候又显示回来,我用百度找到的方法尝试了下,发现会导致页面没法滚动了,但是加到非MUI项目上又可以这样处理?请问有什么办法可以处理呢?
我用的方法是这种```javascript
window.onload = function() {
if(document.documentElement.scrollHeight <= document.documentElement.clientHeight) {
bodyTag = document.getElementsByTagName('body')[0];
bodyTag.style.height = document.documentElement.clientWidth / screen.width * screen.height + 'px';
}
setTimeout(function() {
window.scrollTo(0, 1)
}, 0);
mui('body').on('tap', 'a', function() {
document.location.href = this.href;
})
mui('.mui-draggable .mui-content').scroll({
scrollY: true, //是否竖向滚动
scrollX: false, //是否横向滚动
startX: 0, //初始化时滚动至x
startY: 0, //初始化时滚动至y
indicators: true, //是否显示滚动条
deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
bounce: false //是否启用回弹
});
}
0 个回复