idiotWu / smooth-scrollbar

Customizable, Extendable, and High-Performance JavaScript-Based Scrollbar Solution.
https://idiotwu.github.io/smooth-scrollbar/
MIT License
3.32k stars 384 forks source link

Scrollbars not setted until first mousewheel event. #79

Closed ghost closed 7 years ago

ghost commented 7 years ago

Issue Summary

Browsers tested: Chrome + Safari in mac

Current Behavior

When Scrollbar initalizes, the scrollbars and functions like scrollTo are not set until user scrolls.

Steps to Reproduce

I have a staging here -> http://www.ssll.zalo.nyc/

You can see what I'm saying in two ways:

1) Load the home (http://www.ssll.zalo.nyc/) and try to click on the arrow to scroll down. It doesn't work until you scroll a little with the mouse.

2) In the console you can play with the scrollbar instance under the var Scroll. To test it you can use the function Scroll.scrollTo(0, 50, 1700); (it only works after user has been scrolled)

Online demo

http://www.ssll.zalo.nyc/

idiotWu commented 7 years ago

I think this issue is due to dynamically inserted contents. I would suggest you call scrollbar.update(true) after appending contents.

P.S. true will force an asynchronous update (uses requestAnimationFrame).

ghost commented 7 years ago

A) I'm using scroll.update and it doesn't work in the first load.

B) the first load is not rendering dynamic contents, it's a plain php without ajax (only some images are load asynchronously, but they replace an existing low res image)

Zalo Lorza Planes US: +1 (917) 344-0475 ES: +34 686 513 584 gon@zalo.cat www.zalo.cat

El 22 juny 2017, a les 2:11 a. m., Dolphin Wood notifications@github.com va escriure:

I think this issue is due to dynamically inserted contents. I would suggest you to call scrollbar.update(true) after appending contents.

P.S. true will force an asynchronous update (uses requestAnimationFrame).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

idiotWu commented 7 years ago

So what about calling scrollbar.update() (synchronously) in click event handler?

ghost commented 7 years ago

It works! thanks!