ScrollAnimate
Animate on scroll.
Use
If you want to stop the scroll during animations
Import ScrollAnimate.js
// In index.js
// Or in index.html<script src="scrollAnimate.js"></script>
Init scrollAnimate
var scrollAnimate = wrapper onAnimatingUpdate // If you want the scroll to stop during animation,// use onAnimatingUpdate to update the wrapper overflow like so : { documentstyleoverflow = isAnimating ? 'hidden' : 'auto'}
Name | Type | Description |
---|---|---|
wrapper | DOM element | Main wrapper, scrollAnimate add event listeners to this wrapper |
onAnimatingUpdate | function(isAnimating) | Callback triggered when the animating state change |
Create new animation
var animation = scrollAnimate
Name | Type | Description |
---|---|---|
element | DOM element | Element animated, required to determine when the animation should trigger |
triggerOffsetTop | int | Add offset top before animation triggers |
scrollForComplete | int | Amount of virtual scroll required to complete the animation, the more the longer |
onProgressUpdate | function(progress) | Callback when animation progress update. progress is between 0 and 1 |
Example
let wrapper = documentlet timeline1 = documentlet timeline2 = document let scrollAnimate = wrapper onAnimatingUpdate { wrapperstyleoverflow = isAnimating ? 'hidden' : 'auto'} let animation1 = scrollAnimate let animation2 = scrollAnimate
Todo
- Reverse mode
- Tests