If you want to monitor user activity after reaching the bottom or top of the page, in addition to tracking the scroll event, it's important to also track the wheel event. Furthermore, on mobile devices, tracking touchstart and touchmove events is necessary.
Since not all browsers normalize these events consistently, I created my own normalization function that looks something like this:
var compulsivity = Math.log2(Math.max(scrollAmount, 0.01) * wheelAmount);
Below is a complete interactive playground where you can test these tracking functionalities. It works best in Chrome using Mobile View in Developer Tools, or with TouchEmulator for other browsers.
// JavaScript code for tracking user activity
// ...
.ui-page {
touch-action: none;
}
h1, h2, h3, h4, h5, h6, p {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Custom CSS styles */
<!-- HTML markup and dependencies -->
Another important aspect to consider is the pull-to-refresh feature and the inertia or momentum of smooth scrolling behaviors. Be sure to observe how the events are tracked by scrolling or swiping, as indicated by color changes in the top and bottom bars of the page.