data-scroll-animation v1.3.0
scroll-based HTMLElement property management
Installation
npm install data-scroll-animation
Usage
data-scroll-parent attribute
Specifies the start and end point of nested animation
data-scroll-top
Defines top offset in px
data-scroll-bottom
Defines bottom offset in px
The animation begins at start - topOffset and ends at end + bottomOffset
┌-------------------> topOffset = frame 0
|
|
╔═════════════════╗-> start
║ ║
║ PARENT ║
║ ║
╚═════════════════╝-> end
|
|
└-------------------> bottomOffset = frame 1data-scroll-(property)-(frame)="(value)"
Sets
propertyof the attribute owner element tovalueat specifiedframe
propertyhave format[property.]*property, sostyle.widthworks as wellcustomProperty
valueis linearly interpolated between frames specialframes are "before" and "after"
data-scroll-(method)()
Calls
methodevery frame with frame number as first and only argumentmethod(frame: number): numberimport * as ScrollAnimation from "data-scroll-animation";
ScrollAnimation.add(document.body); // adds all animation in the document ScrollAnimation.add(document.querySelector("#animation")) // adds only the #animation element
ScrollAnimation.remove(document.querySelector("#element")) // removes only the #element element