javascript - 重新初始化 iscroll

标签 javascript html iscroll

我正在为我的项目使用 iScroll4 ( http://cubiq.org/iscroll-4 )

随着容器高度的变化,我需要为 dom 元素重新初始化 iscroll。无论如何我可以做到这一点

例如

scroller.reset();

谢谢。

最佳答案

是的,您需要 refresh()功能:

iScroll needs to know the correct dimensions of both the wrapper and the scroller. They are computed the first time at start up but if your code changes the elements size, iScroll needs to be warned that you are messing with the DOM.

This is achieved by calling the refresh function with the right timing. Please follow me closely, understanding this will save you hours of scrolling frustration.

您可以按如下方式使用它:

myScroll.refresh();

myScroll 代表您初始化 iScroll 的变量。

关于javascript - 重新初始化 iscroll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15762310/

相关文章:

html - 在 div 元素中显示图像的一部分

javascript - CSS/JS : Targeting :nth-child consistant across 2 parent elements?

html - Iscroll 中的固定元素

javascript - 创建内容动态变化的 HTML 表格

html - 有序列表与 css 和 html 中的其余部分一样排列

jQuery Waypoints 不适用于绝对定位的 div

javascript - 如何在 Android 上的 WebView 中提高 JS 可拖动菜单的性能

javascript - Passport 回调500服务器错误

javascript - 使用 jQuery 在点击时隐藏 parent 的 parent 的 div

javascript - 未收到POST参数 Swagger3.0/OpenAPI