Skip to content

Commit 88efcc8

Browse files
committed
Update README.md
1 parent 80bc0fd commit 88efcc8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useEffect } from "react";
3636
import { useAnimation } from "react-animatable";
3737

3838
export const App = () => {
39+
// Define your animation in WAAPI way
3940
const animate = useAnimation(
4041
[
4142
{ fill: "red", fontSize: "24px" },
@@ -50,13 +51,29 @@ export const App = () => {
5051
);
5152

5253
useEffect(() => {
54+
// And play it!
5355
animate.play();
5456
}, []);
5557

5658
return (
57-
<svg width={600} height={400} viewBox="0 0 600 400">
59+
<svg
60+
width={600}
61+
height={400}
62+
viewBox="0 0 600 400"
63+
onClick={
64+
// The return value of useAnimation and its methods are memoized
65+
animate.pause
66+
}
67+
>
5868
<g transform="translate(50, 50)">
59-
<text ref={animate.ref}>Hello world</text>
69+
<text
70+
ref={
71+
// You have to pass ref to element you want to control
72+
animate.ref
73+
}
74+
>
75+
Hello world
76+
</text>
6077
</g>
6178
</svg>
6279
);

0 commit comments

Comments
 (0)