-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[useScrollTrigger] Enhance trigger, improve tests #15634
Conversation
No bundle size changes comparing 1555e52...192cc8e |
@oliviertassinari It's a little early here, but I ran through all the combinations of undefined, zero and a number for current & previous and I think it checkouts out. It also works correctly in my application use case. We can also simplify a little more and delete this line right?
I think it is redundant and not needed after the changes you made. |
@cvanem To try, does it break the tests? |
@oliviertassinari It passed when I tested locally earlier. I can look at it more tomorrow if needed or you can push it if you want. I’m AFK right now. |
What's the exact diff that I should test? |
@oliviertassinari I was going to push more tests, but I was wondering if you think we need to support negative threshold values or not? Currently, I think it breaks with negative thresholds. |
@cvanem How can the scroll value be negative in the first place? |
@oliviertassinari I am pretty sure I have seen negative values on mobile devices with scroll bouncing and over scroll. I think it can also happen on desktops using touch devices for scrolling, like here. I don't have a desktop touch device to test easily. According to this issue, it can happen on MacOS. |
@oliviertassinari To effectively track the trigger state with 0, undefined and negative values, I think we were missing the initialState. I went ahead and added an undocumented initialState prop and added more exhaustive tests. It seems to pass all the tests I could throw at it. Let me know what you think or if we should go back to the previous implementation? |
@cvanem I don't think that we need an |
The threshold is exclusive now, it was inclusive before. I don't know what's the best option, I have updated the documentation at least. |
@oliviertassinari Ok thanks for the update. Just curious, were the brute force tests removed because it is bad practice or for speed? |
@cvanem It was slow, but more importantly, it was testing all the combinations of a few branch logic. I think that we are better off with the scenarios you first wrote. They are closer to how the hook is used in real life. |
Let me know if you want me to create separate issues for the below items. This feature is relatively new so a PR alone may be appropriate.
Hook Updates
Default Trigger Updates
Test Updates