Skip to content

Commit c3d7fd4

Browse files
authored
Featherweight API (#2814)
* Adding support for linear easing * Fixing tests * Renaming animateStyle to startWaapiAnimation * Adding entrypoints: * adding native animator * Removing spring from sequence bundle * Fixing comment * Adding polyfill and test * Adding test * Latest tests * Latest tests * Updating easing * Latest * Latest * Adding tests * Latest * Updating entry names * Latest filesize improvements * fixing * Laetst * Fixing test * Latest
1 parent b544cce commit c3d7fd4

File tree

106 files changed

+5171
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+5171
-481
lines changed

dev/html/public/optimized-appear/defer-handoff-block.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-external-values.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-ancestor-suspend.html

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<script type="module">
3636
const {
3737
motion,
38-
animateStyle,
3938
animate,
4039
startOptimizedAppearAnimation,
4140
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-ancestor.html

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<script type="module">
3636
const {
3737
motion,
38-
animateStyle,
3938
animate,
4039
startOptimizedAppearAnimation,
4140
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-child.html

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<script type="module">
3636
const {
3737
motion,
38-
animateStyle,
3938
animate,
4039
startOptimizedAppearAnimation,
4140
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-opacity.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-sibling-transform.html

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<script type="module">
3636
const {
3737
motion,
38-
animateStyle,
3938
animate,
4039
startOptimizedAppearAnimation,
4140
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-sibling.html

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<script type="module">
3636
const {
3737
motion,
38-
animateStyle,
3938
animate,
4039
startOptimizedAppearAnimation,
4140
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-useeffect.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout-uselayouteffect.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff-layout.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/defer-handoff.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/interrupt-delay-after.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-delay-before-accelerated.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-delay-before.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-spring.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-tween-opacity-waapi.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-tween-opacity.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-tween-transforms.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/interrupt-tween-x.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/persist-optimised-animation.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
animate,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,

dev/html/public/optimized-appear/persist.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/portal.html

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<script type="module">
2828
const {
2929
motion,
30-
animateStyle,
3130
startOptimizedAppearAnimation,
3231
optimizedAppearDataAttribute,
3332
motionValue,

dev/html/public/optimized-appear/resync-delay.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/resync.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,

dev/html/public/optimized-appear/start-after-hydration.html

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<script type="module">
2727
const {
2828
motion,
29-
animateStyle,
3029
startOptimizedAppearAnimation,
3130
optimizedAppearDataAttribute,
3231
motionValue,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { animateMini } from "framer-motion/dom"
2+
import { useRef, useEffect } from "react"
3+
4+
export const App = () => {
5+
const ref = useRef<HTMLDivElement>(null)
6+
7+
useEffect(() => {
8+
if (!ref.current) return
9+
10+
const animation = animateMini(
11+
ref.current,
12+
{ width: 200 },
13+
{ duration: 0.1, autoplay: false }
14+
)
15+
16+
return () => animation.cancel()
17+
}, [])
18+
19+
return <div id="box" ref={ref} style={style} />
20+
}
21+
22+
const style = {
23+
width: 100,
24+
height: 100,
25+
backgroundColor: "#fff",
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { animateMini } from "framer-motion/dom"
2+
import { useRef, useEffect } from "react"
3+
4+
export const App = () => {
5+
const ref = useRef<HTMLDivElement>(null)
6+
7+
useEffect(() => {
8+
if (!ref.current) return
9+
10+
const animation = animateMini(
11+
ref.current,
12+
{ width: 200 },
13+
{ duration: 20 }
14+
)
15+
16+
animation.complete()
17+
18+
return () => animation.cancel()
19+
}, [])
20+
21+
return <div id="box" ref={ref} style={style} />
22+
}
23+
24+
const style = {
25+
width: 100,
26+
height: 100,
27+
backgroundColor: "#fff",
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { spring } from "framer-motion"
2+
import { animate } from "framer-motion/dom/mini"
3+
import { useRef, useEffect } from "react"
4+
5+
export const App = () => {
6+
const ref = useRef<HTMLDivElement>(null)
7+
8+
useEffect(() => {
9+
if (!ref.current) return
10+
11+
ref.current.style.backgroundColor = "red"
12+
13+
let animation = animate(
14+
ref.current,
15+
{ width: [null, 200] },
16+
{ duration: 0.1 }
17+
)
18+
19+
if (animation.duration === 0.1) {
20+
animation = animate(ref.current, { width: [null, 200] }, {})
21+
22+
if (animation.duration === 0.3) {
23+
animation = animate(
24+
ref.current,
25+
{ width: [null, 200] },
26+
{ type: spring }
27+
)
28+
29+
if (animation.duration === 1.06) {
30+
ref.current.style.backgroundColor = "green"
31+
}
32+
}
33+
}
34+
35+
return () => {
36+
animation.cancel()
37+
}
38+
}, [])
39+
40+
return (
41+
<div id="box" ref={ref} style={style}>
42+
content
43+
</div>
44+
)
45+
}
46+
47+
const style = {
48+
width: 100,
49+
height: 100,
50+
backgroundColor: "#fff",
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { animateMini } from "framer-motion/dom"
2+
import { useRef, useEffect } from "react"
3+
4+
export const App = () => {
5+
const ref = useRef<HTMLDivElement>(null)
6+
7+
useEffect(() => {
8+
if (!ref.current) return
9+
10+
const animation = animateMini(
11+
ref.current,
12+
{ width: 200 },
13+
{ duration: 2 }
14+
)
15+
16+
const timer = setTimeout(() => {
17+
if (!ref.current) return
18+
animateMini(ref.current, { width: 100 }, { duration: 0.5 })
19+
}, 1000)
20+
21+
return () => {
22+
animation.cancel()
23+
clearTimeout(timer)
24+
}
25+
}, [])
26+
27+
return (
28+
<div id="box" ref={ref} style={style}>
29+
content
30+
</div>
31+
)
32+
}
33+
34+
const style = {
35+
width: 100,
36+
height: 100,
37+
backgroundColor: "#fff",
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { animateMini } from "framer-motion/dom"
2+
import { useRef, useEffect } from "react"
3+
4+
export const App = () => {
5+
const ref = useRef<HTMLDivElement>(null)
6+
7+
useEffect(() => {
8+
if (!ref.current) return
9+
10+
const animation = animateMini(
11+
ref.current,
12+
{ width: 200 },
13+
{ duration: 0.2 }
14+
)
15+
16+
setTimeout(() => {
17+
animation.pause()
18+
}, 100)
19+
20+
animation.pause()
21+
22+
return () => animation.cancel()
23+
}, [])
24+
25+
return <div id="box" ref={ref} style={style} />
26+
}
27+
28+
const style = {
29+
width: 100,
30+
height: 100,
31+
backgroundColor: "#fff",
32+
}

0 commit comments

Comments
 (0)