A slim smooth-scrolling script under 300 bytes (gzipped), with no other dependencies (No jQuery).
540 bytes gzipped
1010 bytes uncompressed
The base includes support for four types of scroll-targets:
- Position in pixels ( eg.
slimScroller.scroll(200)
) - CSS selector ( eg.
slimScroller.scroll("p:first-of-type")
) - Direct JavaScript HTML-element ( eg.
slimScroller.scroll(document.querySelector(p#hi))
)
By executing slimScroller.bind()
when the dom finishes loading, SlimScroller will also animate same-page hashtag-scrolling in anchor tags.
282 bytes gzipped
464 bytes uncompressed
The small version includes support for one type of scroll-target:
- CSS selector ( eg.
slimScroller.scroll("p:first-of-type")
)
Just use the slimScroller.scroll
-function with the following parameters.
Required
Scroll-target according to SlimScroller-versionOptional
Duration inms
Optional
Switch to horizontal-scrolling inboolean
Optional
Callback-function with resulting scroll-position as parameter
Yes. Use npm install slimscroller
.
This is a smaller fork of alicelieutier's smoothScroll.