简体   繁体   English

防止在iScroll4中弹回到原始位置

[英]Prevent snapback to original position in iScroll4

I'm using iScroll4 to make a certain element scrollable in my webpage but it snaps back to the original position once you release the mouse/touch. 我正在使用iScroll4使某个元素在我的网页中可滚动,但是一旦释放鼠标/触摸,它就会回到原始位置。 How do I make it stay instead? 我如何使其停留?

I think that I have figured out why this happens. 我认为我已经弄清楚了为什么会这样。 I had iscroll4 working in a Phonegap app that I was building, and then broke it after changing some CSS. 我在正在构建的Phonegap应用中使用过iscroll4,然后在更改了一些CSS之后将其破坏了。 At the time, I didn't realize what I had done and I spent a long time hunting for a Javascript solution. 当时,我不知道自己做了什么,花了很长时间寻找Javascript解决方案。

Finally, I noticed that when I tested it in a browser, there was a scrollbar for the list where I was using iscroll4. 最终,我注意到,当我在浏览器中对其进行测试时,存在一个滚动条,用于显示使用iscroll4的列表。 And when I tried to scroll, the scrollbar thumb changed size. 当我尝试滚动时,滚动条的拇指会更改大小。 That is why it was snapping back. 这就是为什么它突然反弹。 The browser made the wrapper div big enough to hold the entire list, so whenever I tried to scroll, there was no hidden data so I triggered the pull-up event and then the browser resized the div. 浏览器使包装器div足够大以容纳整个列表,因此,每当我尝试滚动时,都没有隐藏数据,因此我触发了上拉事件,然后浏览器调整了div的大小。

I had to change the CSS to include overflow:hidden and it started to work again. 我必须更改CSS以使其包含overflow:hidden然后它再次开始工作。 I tried overflow:hidden on the ul tag and the scroller div but that didn't work. 我尝试了overflow:hiddenul标签和scroller div上,但这scroller It has to be on the wrapper div. 它必须在wrapper div上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM