-
Notifications
You must be signed in to change notification settings - Fork 1k
experimental: Stagger Animation #5066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3a1bbe5
7d970e8
2208e28
6b8d58d
17d07c6
ad92e30
23f0637
f213b77
a4da403
c962484
3872864
05cf8f7
250a317
59a9008
9771b25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { AnimateChildren } from "./animate-children"; | ||
export { AnimateText } from "./animate-text"; | ||
export { StaggerAnimation } from "./stagger-animation"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { meta as AnimateChildren } from "./animate-children.ws"; | ||
export { meta as AnimateText } from "./animate-text.ws"; | ||
export { meta as StaggerAnimation } from "./stagger-animation.ws"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { propsMeta as AnimateChildren } from "./animate-children.ws"; | ||
export { propsMeta as AnimateText } from "./animate-text.ws"; | ||
export { propsMeta as StaggerAnimation } from "./stagger-animation.ws"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { forwardRef, type ElementRef } from "react"; | ||
|
||
const easings = { | ||
linear: true, | ||
easeIn: true, | ||
easeInCubic: true, | ||
easeInQuart: true, | ||
easeOut: true, | ||
easeOutCubic: true, | ||
easeOutQuart: true, | ||
ease: true, | ||
easeInOutCubic: true, | ||
easeInOutQuart: true, | ||
}; | ||
|
||
type StaggerAnimationProps = { | ||
/** | ||
* Size of the sliding window for the animation: | ||
* - 0: Typewriter effect (no animation). | ||
* - (0..1]: Animates one child at a time. | ||
* - (1..n]: Animates multiple children within the sliding window. | ||
*/ | ||
slidingWindow?: number; | ||
/** | ||
* Easing function applied within the sliding window. | ||
*/ | ||
easing?: keyof typeof easings; | ||
/** | ||
* Text content to animate. | ||
*/ | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const StaggerAnimation = forwardRef< | ||
ElementRef<"div">, | ||
StaggerAnimationProps | ||
>(({ slidingWindow = 1, easing = "linear", ...props }, ref) => { | ||
istarkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Implementation is located in private-src | ||
return <div ref={ref} {...props} />; | ||
}); | ||
|
||
const displayName = "StaggerAnimation"; | ||
StaggerAnimation.displayName = displayName; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { StaggerAnimationIcon } from "@webstudio-is/icons/svg"; | ||
import type { WsComponentMeta, WsComponentPropsMeta } from "@webstudio-is/sdk"; | ||
import { props } from "./__generated__/stagger-animation.props"; | ||
|
||
export const meta: WsComponentMeta = { | ||
category: "animations", | ||
type: "container", | ||
description: | ||
"Stagger animation allows you to animate children elements with a sliding window.", | ||
icon: StaggerAnimationIcon, | ||
order: 6, | ||
label: "Stagger Animation", | ||
constraints: [ | ||
{ relation: "parent", component: { $eq: "AnimateChildren" } }, | ||
{ | ||
relation: "child", | ||
text: false, | ||
}, | ||
], | ||
}; | ||
|
||
export const propsMeta: WsComponentPropsMeta = { | ||
props, | ||
initialProps: ["slidingWindow", "easing"], | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.