Smooth scroll
Smoothly animate the playback progress of the linked object to the scroll position by passing a value between 0 and 1. The closer the value gets to 0, the longer the animation takes to catch up with the current scroll position. At .99 the smoothing is barely visible, at .5 the animation catches up in about a second, and at .1 in about 8 seconds.
Since version 5.0.0, values close to 1 catch up faster and values close to 0 catch up slower, like .99 catching up in about 0.07 seconds instead of 0.4, and .1 in about 8 seconds instead of 3.
Accepts
A Number greater than or equal to 0 and lower to or equal 1
Smooth scroll code example
import { animate, onScroll } from 'animejs';
animate('.square', {
x: '15rem',
rotate: '1turn',
ease: 'linear',
autoplay: onScroll({
container: '.scroll-container',
enter: 'bottom-=50 top',
leave: 'top+=60 bottom',
sync: .5,
debug: true,
})
});
<div class="full-container scroll-container scroll-y">
<div class="scroll-content grid square-grid">
<div class="scroll-section padded">
<div class="large row">
<div class="label">scroll down</div>
</div>
</div>
<div class="scroll-section padded">
<div class="large row">
<div class="square"></div>
</div>
</div>
<div class="scroll-section">
</div>
</div>
</div>