gpt4 book ai didi

javascript - 重新初始化 iscroll

转载 作者:可可西里 更新时间:2023-11-01 13:13:25 25 4
gpt4 key购买 nike

我正在为我的项目使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com