Fire when scrolling up rapidly to the top of the page #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @carlsednaoui,
could you please take a look at this pull request? It's implementing the feature requested in #74, which has been renewed in #84 and also addresses the needs of our own clients at Darwin Pricing. @kevinweber @roblb for your information:
The popup will be fired whenever someone scrolls back rapidly to the top of the page, which is the best guess you can make about someone's willingness to leave the site on touch devices.
I'm not looking at whether we are actually on a touch device, because there are more and more hybrid devices like desktop computers with both a mouse/trackpad and a touch screen.
The change set is the following:
scrollSpeed
, set to 1000 pixels per second by default. This scrolling speed is the threshold to trigger the popup whenever the user scrolls back to the top of the page.mouseenter
event bymousemove
for this purpose.window.scrollY <= 0
because some browsers use negative offsets while they render a bounce animation when the user scrolls back to the top of the page.I'm not sure how to run the test suite, so I haven't added a unit test for that. Feel free to do it if you have some slack!
It would be great if you could review and discuss this pull request in the next few days!