Skip to content

Commit

Permalink
Featherweight API (#2814)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mattgperry authored Sep 27, 2024
1 parent b544cce commit c3d7fd4
Show file tree
Hide file tree
Showing 106 changed files with 5,171 additions and 481 deletions.
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/defer-handoff-block.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/defer-handoff-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/defer-handoff.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/interrupt-spring.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/interrupt-tween-x.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
animate,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/persist.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/resync-delay.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
1 change: 0 additions & 1 deletion dev/html/public/optimized-appear/resync.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<script type="module">
const {
motion,
animateStyle,
startOptimizedAppearAnimation,
optimizedAppearDataAttribute,
motionValue,
Expand Down
26 changes: 26 additions & 0 deletions dev/react/src/tests/animate-style-autoplay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { animateMini } from "framer-motion/dom"
import { useRef, useEffect } from "react"

export const App = () => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return

const animation = animateMini(
ref.current,
{ width: 200 },
{ duration: 0.1, autoplay: false }
)

return () => animation.cancel()
}, [])

return <div id="box" ref={ref} style={style} />
}

const style = {
width: 100,
height: 100,
backgroundColor: "#fff",
}
28 changes: 28 additions & 0 deletions dev/react/src/tests/animate-style-complete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { animateMini } from "framer-motion/dom"
import { useRef, useEffect } from "react"

export const App = () => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return

const animation = animateMini(
ref.current,
{ width: 200 },
{ duration: 20 }
)

animation.complete()

return () => animation.cancel()
}, [])

return <div id="box" ref={ref} style={style} />
}

const style = {
width: 100,
height: 100,
backgroundColor: "#fff",
}
51 changes: 51 additions & 0 deletions dev/react/src/tests/animate-style-duration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { spring } from "framer-motion"
import { animate } from "framer-motion/dom/mini"
import { useRef, useEffect } from "react"

export const App = () => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return

ref.current.style.backgroundColor = "red"

let animation = animate(
ref.current,
{ width: [null, 200] },
{ duration: 0.1 }
)

if (animation.duration === 0.1) {
animation = animate(ref.current, { width: [null, 200] }, {})

if (animation.duration === 0.3) {
animation = animate(
ref.current,
{ width: [null, 200] },
{ type: spring }
)

if (animation.duration === 1.06) {
ref.current.style.backgroundColor = "green"
}
}
}

return () => {
animation.cancel()
}
}, [])

return (
<div id="box" ref={ref} style={style}>
content
</div>
)
}

const style = {
width: 100,
height: 100,
backgroundColor: "#fff",
}
38 changes: 38 additions & 0 deletions dev/react/src/tests/animate-style-interrupt.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { animateMini } from "framer-motion/dom"
import { useRef, useEffect } from "react"

export const App = () => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return

const animation = animateMini(
ref.current,
{ width: 200 },
{ duration: 2 }
)

const timer = setTimeout(() => {
if (!ref.current) return
animateMini(ref.current, { width: 100 }, { duration: 0.5 })
}, 1000)

return () => {
animation.cancel()
clearTimeout(timer)
}
}, [])

return (
<div id="box" ref={ref} style={style}>
content
</div>
)
}

const style = {
width: 100,
height: 100,
backgroundColor: "#fff",
}
32 changes: 32 additions & 0 deletions dev/react/src/tests/animate-style-pause.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { animateMini } from "framer-motion/dom"
import { useRef, useEffect } from "react"

export const App = () => {
const ref = useRef<HTMLDivElement>(null)

useEffect(() => {
if (!ref.current) return

const animation = animateMini(
ref.current,
{ width: 200 },
{ duration: 0.2 }
)

setTimeout(() => {
animation.pause()
}, 100)

animation.pause()

return () => animation.cancel()
}, [])

return <div id="box" ref={ref} style={style} />
}

const style = {
width: 100,
height: 100,
backgroundColor: "#fff",
}
Loading

0 comments on commit c3d7fd4

Please sign in to comment.