-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Description
Inspired by the proposal to allow Element-based offsets, I propose we can simplify the startScrollOffset and endScrollOffset props into a single scrollOffsets array.
This would allow us to leverage KeyframeEffect's ability to accept more than two keyframes in an animation.
Example
The "Example 1. Reveal / Unreveal" example in the above ticket shows the definition of two ScrollTimelines, like this:
const revealTimeline = new ScrollTimeline({
startScrollOffset: { target: image, edge: 'start', threshold: 0 },
endScrollOffset: { target: image, edge: 'start', threshold: 100 },
});
const unrevealTimeline = new ScrollTimeline({
startScrollOffset:{ target: image, edge: 'end', threshold: 100}
endScrollOffset:{ target: image, edge: 'end', threshold:0}
});To create one conceptually unique effect (fade in while on screen), we create two timelines, two effects, and two animations.
Instead, we can half this to just one, with a single scrollOffset array:
const timeline = new ScrollTimeline({
source: scroller,
scrollOffsets: [100, 200, 800, 900]
});Taken from @majido's example, this would change the above to:
const timeline = new ScrollTimeline({
scrollOffsets: [
{ target: image, edge: 'start', threshold: 0 },
{ target: image, edge: 'start', threshold: 100 },
{ target: image, edge: 'end', threshold: 100 },
{ target: image, edge: 'end', threshold: 0 }
]
});
const effect = new KeyframeEffect(
image,
{ opacity: [0, 1, 1, 0]},
{ duration: 1000, fill: both }
);
const revealUnrevleaAnimation = new Animation(effect, timeline);
revealUnrevleaAnimation.play();koenbok
Metadata
Metadata
Assignees
Labels
scroll-animations-1Current WorkCurrent Work