Smooth scrolling sections based on VirtualScroll.
yarn add @twotwentytwo/jscroll
import JScroll from '@twotwentytwo/jscroll'
JScroll.init({ /* Options are optional */ })<div data-smooth> <!-- Add data-smooth to your container -->
<div data-smooth-item></div>
<div data-smooth-item></div>
<div data-smooth-item data-speed="1.1"></div> <!-- Use data-speed to control speed of item -->
<div>
<div>
<div data-smooth-item></div> <!-- No need to be top lvl -->
</div>
</div>
<div data-smooth-item>
<div data-smooth-item data-speed="0.75"></div> <!-- Can be nested for parallax effects -->
</div>
</div>ease: Easing value (defaults to 0.1)
scrollbar: Virtual scrollbar (defaults to false)
disableMobile: Disable JScroll on mobile devices (defaults to true)
preload: Trigger resize after loading all images (defaults to false)
vs:
mouseMultiplier: Defaults to 0.45touchMultiplier: Defaults to 2.5firefoxMultiplier: Defaults to 90
init(): Initialise instance
update(): Update instance
resize(): Trigger resize
preload(): Preload images
tick(): Where the magic happens
stop(): Stop scrolling
resume(): Resume scrolling
destroy(): Clean instance
scrollTo(someElement.offsetTop): Anchor scroll
on('tick', ({ target, current }) => {}): Raf callback. Scroll and lerped scroll params.
on('scroll', ({ delta, target }) => {}): Scroll callback. Delta and scroll params.
getSmooth: Returns lerped scroll value
getScroll: Returns scroll value
Some great examples of sites using JScroll.