<ScrollContainer snap="mandatory">
<ScrollPage>
<Animator animation={batch(Fade(), Sticky(), MoveOut(0, -200))}>
<MediumText>Let me show you scroll animation 😀</MediumText>
</Animator>
</ScrollPage>
</ScrollContainer>
-
ScrollContainer
must be root -
ScrollContainer
's children snap option is optional ('none' | 'mandatory' | 'proximity'
) -
ScrollContainer
's children must beScrollPage
-
ScrollPage
isposition: relative;
thus, if you want use flexbox, makediv
inScrollPage
-
Animator
must be inScrollPage
-
Animator
hasanimation
props
const ZoomInScrollOut = batch(StickyIn(), FadeIn(), ZoomIn());
const FadeUp = batch(Fade(), Move(), Sticky());
- You can use just single animation likes
Fade()
,Move()
, ... - If you want to combinate serveral animations, use
batch(...animations
) - There's Fade, Move, Sticky, Zoom
-
Fade( from:number, to:number )
from
: initial opacity number (0~1), default0
to
: final opacity number (0~1), default1
-
FadeIn( ... )
,FadeOut( ... )
FadeIn
is for only in-animationFadeOut
is for only out-animation- Also,
MoveIn
,MoveOut
,StickyIn
,StickyOut
,ZoomIn
,ZoomOut
is there, and I'll skip writing descriptions about these In/Out
-
Move( dx:number, dy:number, outDx:number, outDy:number )
dx
: initial x value (unit: px), default0
dy
: initial y value (unit: px), default100
outDx
: final x value, defaultnull
outDy
: final y value, default-100
- If outDx is null, then use dx value rather than outDx, outDy too.
-
Sticky( left:number, top:number )
left
: value of style.left (unit: %), default50
(%)top
: value of style.top (unit: %), default50(%)
-
Zoom( from:number, to:number )
from
: initial scale value, default10
to
: final scale value, default1
-
batch( ...animations )
{
in: {
style: { ... }
},
out: {
style: { ... }
}
}
-
Each
style
object will be used as react propsstyle
-
But, there's one thing different
{ in: { style: { opacity: (value) => value } }, out: { style: { opacity: (value) => (1 - value) } } }
Like this, style's value can be
function
type with 1 parameter (name is value)value
is number between 0~1, that means percentage of scroll completionUpper animation object's opacity value will acts like 0 -> 1 -> 0, during scroll-up