0.6.7
(scrollConfig)
import { Scroll } from 'fizban';
const scroll = new Scroll({
scenes: [...]
});
scroll.start();
Setup event and effect, and reset progress and frame.
Removes event listener.
Calculate current progress.
Stop the event and effect, and remove all DOM side-effects.
Register to scroll for triggering update.
Remove scroll handler.
Reset registered effect.
Remove registered effect.
Type: object
(Array<ScrollScene>)
: list of effect scenes to perform during scroll.
(boolean?)
: whether to animate effect progress.
(number?)
: between 0 to 1, amount of friction effect in the transition. 1 being no movement and 0 as no friction. Defaults to 0.4.
(boolean?)
: whether to calculate velocity with progress.
(number?)
: max possible value for velocity. Velocity value will be normalized according to this number, so it is kept between 0 and 1. Defaults to 1.
(boolean?)
: whether to observe entry/exit of scenes into viewport for disabling/enabling them. Defaults to
true
.
(boolean?)
: rootMargin
option to be used for viewport observation. Defaults to
'7% 7%'
.
(boolean?)
: whether to observe resize of the layout viewport. Defaults to
false
.
(boolean?)
: whether to observe resize of view-timeline source elements. Defaults to
false
.
A configuration object for a scene. Must be provided an effect function, and either a start and end, a start and duration, or a duration as RangeName.
Type: Object
(EffectCallback)
: the effect to perform.
((number | RangeOffset))
: scroll position in pixels where effect starts.
((number | RangeOffset)?)
: scroll position in pixels where effect ends. Defaults to start + duration.
(boolean?)
: whether to perform updates on the scene. Defaults to false.
(Element?)
: an element to be used for observing intersection with viewport for disabling/enabling the scene, or the source of a ViewTimeline if scene start/end are provided as ranges.
(function?)
: a function clean up the scene when it's controller is destroyed.
(string?)
: a string id for a group of scenes sharing same viewSource and part of the same overall animation
{ effects: (scene, p) => { animation.currentTime = p; }, duration: 'contain' }
Type: function (scene: ScrollScene, progress: number, velocity: number): void
Type: Object
Type:
("entry"
| "contain"
| "exit"
| "cover"
| "entry-crossing"
| "exit-crossing"
)
Type: Object
(number)
(("px"
| "vh"
| "vw"
))
Type: Object
((Window | HTMLElement))
(boolean)
number
:
Scroll controller.
Removes all side effects and deletes all objects.
parses offsetString of the format calc( + )
(AbsoluteOffsetContext)
Convert an absolute offset as string to number of pixels
(AbsoluteOffsetContext)
number
:
Convert a range into offset in pixels.
number
:
Convert scene data in ranges into offsets in pixels.
(ScrollScene)
(number)
(boolean)
(AbsoluteOffsetContext)
(any)
ScrollScene
:
Check whether the position of an element is sticky.
(CSSStyleDeclaration)
boolean
:
Get start offset of an element in scroll direction.
(CSSStyleDeclaration)
(boolean)
number
:
Get end offset of an element in scroll direction.
(CSSStyleDeclaration)
(boolean)
number
:
number
:
Returns an array of converted scenes' data for grouped scenes (assumes same viewSource) from ranges into offsets in pixels.
(Array<ScrollScene>)
((Window | HTMLElement))
(number)
(boolean)
(AbsoluteOffsetContext)
Array<ScrollScene>
:
Returns a converted scene data from ranges into offsets in pixels.
(ScrollScene)
((Window | HTMLElement))
(number)
(boolean)
(AbsoluteOffsetContext)
ScrollScene
:
Debounce a function by interval in milliseconds.
function
: