d4nyll / smartscroll

jQuery plugin for scrolljacking and auto-hashing
https://d4nyll.github.io/smartscroll/
MIT License
257 stars 45 forks source link

Odd behaviour on initial scroll in Chrome #26

Closed ghost closed 8 years ago

ghost commented 8 years ago

When I first start to scroll, and I am on the first section. It seems as though regardless of whether I swipe up or down. The page begins to animate as though I am scrolling down. You can see this effect in the demo here (http://d4nyll.github.io/smartscroll/different-heights/). If you scroll up the page will scroll down as though you were scrolling down.

Note this only happens on the initial state. Once you have commenced scrolling you cannot then scroll up and cause the page to scroll down.

Is this an intentional effect? As ideally I would like nothing to happen when scrolling up from the first slide.

Hope that makes sense! For the record I am using a Macbook trackpad to scroll and am seeing this effect in Chrome 49 and Canary, but not in Firefox or Safari.

d4nyll commented 8 years ago

Hey @achubb sorry for the late reply. I've been super-busy up til now working on my company.

I have encountered this problem before and it has to do with the trackpad giving erratic 'up' events, as demonstrated in the diagram below:

The red sections below the middle line represents scrolling in one direction, but you can see some erratic peaks in the other direction.

Lethargy (the library smartscroll depends on to determine whether the scroll event is intentional) requires a few (15 if I recall correctly) scroll events for it to work. That's why after scrolling for a while, lethargy is able to determine that those peaks are not intentional and, basically, ignores them.

But lethargy (and mousepads) is not perfect, that's why at the beginning you might still 'scroll up but it scrolls down', but it should still be better than if you don't use lethargy.

You can track this issue on the Lethargy issues tracker instead - https://github.com/d4nyll/lethargy/issues/8.

I hope this explanation makes sense!