昵称不存在
昵称不存在
  • 发布:2016-05-18 10:59
  • 更新:2018-09-20 11:34
  • 阅读:3488

mui方法返回顶部兼容性问题?

分类:MUI

在mui上看到另一位大神的返回顶部方法的代码,我就用了,但是发现,在安卓上无法显示,不知道什么问题,特此贴出来,想问下大神们,怎么解决呀?
var scrollToTopBox = document.getElementById('scrollToTop');
//返回按钮tap
scrollToTopBox.addEventListener('tap', function(e) {
e.stopPropagation();
mui('#pullrefresh').pullRefresh().scrollTo(0, 0, 100);//滚动到顶部
});
//Android上监听原生滚动,iOS上监听div滚动,上拉超过一屏后显示按钮,否则隐藏,可自行在条件判断中修改
if (mui.os.android) {
window.addEventListener('scroll', function(e) {
if (window.pageYOffset >= window.innerHeight && scrollToTopBox.classList.contains('hide'))
scrollToTopBox.classList.remove('hide');
else if (window.pageYOffset < window.innerHeight && !scrollToTopBox.classList.contains('hide'))
scrollToTopBox.classList.add('hide');
});
} else {
document.getElementById('pullrefresh').addEventListener('scrollend', function() {
if (mui('#pullrefresh').pullRefresh().y <= window.innerHeight (-1) && scrollToTopBox.classList.contains('hide'))
scrollToTopBox.classList.remove('hide');
else if (mui('#pullrefresh').pullRefresh().y > window.innerHeight
(-1) && !scrollToTopBox.classList.contains('hide'))
scrollToTopBox.classList.add('hide');
});
}

2016-05-18 10:59 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com - 天下风云出我辈

看清楚了,他是满足条件要有hide这个class。你先给按钮添加个hide class就行了。我用过了,可以

型英正靓帅

型英正靓帅

我也是,点按钮没反应

该问题目前已经被锁定, 无法添加新回复