Skip to content

Commit

Permalink
feat(animations) : wobble animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutesa-Cedric committed Sep 26, 2023
1 parent 2dee020 commit 29f2061
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/animations/simple/Wobble.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import wrapper from "@/HOC/wrapper";
import { animation, defaults } from "@/lib/defaultConfigs";

const rule = `
from {
transform: none;
}
15% {
transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
}
30% {
transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
}
45% {
transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
}
60% {
transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
}
75% {
transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
}
to {
transform: none;
}
`;

let name: string | undefined;
function make() {
return name || (name = animation(rule));
};

export default function Wobble({
children,
_out,
timeout,
duration = defaults.duration,
delay = defaults.delay,
count = defaults.count,
forever, ...props
} = defaults) {
const effect = { make, duration: timeout === undefined ? duration : timeout, delay, forever, count, style: { animationFillMode: 'both', } };
// @ts-expect-error(some props are not allowed, this will be fixed later)
return wrapper(props, effect, false, children, true);
};

2 changes: 2 additions & 0 deletions src/animations/simple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export * from "./RubberBand";
export * from "./Flash";
export * from "./Tada";
export * from "./Swing";
export * from "./Spin";
export * from "./Wobble";

0 comments on commit 29f2061

Please sign in to comment.