提交 1ae71bea 编写于 作者: Q qiang

fix: 解决监听页面滚动(onPageScroll)后切换页面报错的问题

上级 ef75c1ec
......@@ -88,9 +88,9 @@ export default function initSubscribe (subscribe) {
onReachBottomDistance,
enableTransparentTitleNView
})
setTimeout(function () { // 避免监听太早,直接触发了 scroll
requestAnimationFrame(function () { // 避免监听太早,直接触发了 scroll
document.addEventListener('scroll', scrollListener)
}, 10)
})
}
})
}
......
......@@ -91,6 +91,10 @@ export function createScrollListener (pageId, {
}
function trigger () {
const pages = getCurrentPages()
if (!pages.length || pages[pages.length - 1].$page.id !== pageId) {
return
}
// publish
const scrollTop = window.pageYOffset
if (enablePageScroll) { // 向 Service 发送 onPageScroll 事件
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册