If you're searching for a way to create an elastic effect ...
This type of effect necessitates the support of overscroll on DOM elements - essentially, allowing the setting of document.body.scrollTop
to a negative value. However, this cannot be accomplished with standard DOM methods:
$(function() {
document.body.scrollTop = -20;
$("#sp").html("Scroll position=" + document.body.scrollTop);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id=sp>
Scroll position
</div>
To achieve the desired animated elastic effect, you will need to animate document.body.scrollTop < 0
.
In addition to negative scroll values, a special type of scrollbar is required. The default classic scrollbars are not equipped to display overscroll positions.
Ultimately, browser support is necessary in order to attain such an effect.
In my own project, Sciter, I implemented the CSS property overlow:scroll-indicator;
to enable a lightweight scrollbar with an animated "go back" effect. Below is a screenshot capturing the moment of overscroll (note that the first item is off the top of the list):
https://i.sstatic.net/zUKw0.png
Theoretically, achieving this effect in browsers involves using animated transform:translate()
and custom scrollbar-like drawing techniques, but as of now, such implementations seem to be rare...