<ScrollContainer>
<ScrollPage page={0}>
<Animator animation={batch(Fade(), Sticky(), MoveOut(0, -200))}>
<MediumText>Let't me show you scroll animation π</MediumText>
</Animator>
</ScrollPage>
<ScrollContainer>-
ScrollContainermust be root -
ScrollContainer's children must beScrollPage -
ScrollPageisposition: relative;thus, if you want use flexbox, makedivinScrollPage -
ScrollPagehaspageprops for integer(Honestly, I don't like this way, is there awesome solution?)
-
Animatormust be inScrollPage -
Animatorhasanimationprops
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), default0to: final opacity number (0~1), default1
-
FadeIn( ... ),FadeOut( ... )FadeInis for only in-animationFadeOutis for only out-animation- Also,
MoveIn,MoveOut,StickyIn,StickyOut,ZoomIn,ZoomOutis 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), default0dy: initial y value (unit: px), default100outDx: final x value, defaultnulloutDy: 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, default10to: final scale value, default1
-
batch( ...animations )
{
in: {
style: { ... }
},
out: {
style: { ... }
}
}-
Each
styleobject 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
functiontype with 1 parameter (name is value)valueis number between 0~1, that means percentage of scroll completionUpper animation object's opacity value will acts like 0 -> 1 -> 0, during scroll-up