Skip to content

Commit

Permalink
Merge branch 'main' into update-emotion-is-valid-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry authored Mar 12, 2024
2 parents c30a327 + c2454f1 commit 9767415
Show file tree
Hide file tree
Showing 166 changed files with 2,888 additions and 2,298 deletions.
44 changes: 41 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
},
"useJSXTextNode": true
},
"plugins": ["@typescript-eslint", "react", "react-hooks", "import"],
"extends": ["prettier"],
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"import",
"redos-detector"
],
"extends": ["prettier", "plugin:regexp/recommended"],
"rules": {
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/type-annotation-spacing": "error",
Expand All @@ -31,6 +37,38 @@
// "react-this-binding-issue": 1,
// "react-unused-props-and-state": 1,
// "variable-name": [1, "ban-keywords"]
"use-isnan": "error"
"use-isnan": "error",

// Regexp
// Regexp security
"redos-detector/no-unsafe-regex": ["error", { "ignoreError": true }], // Prevent DoS regexps
"regexp/no-super-linear-move": "error",

// Auto optimize regexps
"regexp/no-non-standard-flag": "warn",
"regexp/no-control-character": "error",
"regexp/no-contradiction-with-assertion": "error",
"regexp/no-octal": "warn",
"regexp/no-standalone-backslash": "error",
"regexp/prefer-escape-replacement-dollar-char": "error",
"regexp/prefer-quantifier": "error",
"regexp/hexadecimal-escape": ["error", "always"],
"regexp/prefer-lookaround": "error",
"regexp/prefer-unicode-codepoint-escapes": "warn",
"regexp/grapheme-string-literal": "error",
"regexp/no-unused-capturing-group": [
"error",
{
"fixable": true,
"allowNamed": true
}
],

// regex perf
"regexp/prefer-question-quantifier": "off", // `(?:a|b|)` is faster than (?:a|b)?
"regexp/no-empty-alternative": "off", // see above
"regexp/require-unicode-regexp": "warn", // /u flag is faster and enables regexp strict mode
"@typescript-eslint/prefer-regexp-exec": "off",
"regexp/prefer-regexp-exec": "error" // exec is faster than match
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/nan-npm-2.16.0-cac314a230-cb16937273.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ Framer Motion adheres to [Semantic Versioning](http://semver.org/).

Undocumented APIs should be considered internal and may change without warning.

## [11.0.11] 2024-03-12

### Changed

- Keyframes now resolved asynchronously.
- External event handlers now fired synchronously.
- CSS variables and unit conversion now supported with >2 keyframe animations.
- Removed WAAPI animation of `background-color`.

## [11.0.10] 2024-03-12

### Fixed

- Improved speed and stability of regexes.

## [11.0.9] 2024-03-12

### Added

- Added support for Content Security Policy (CSP) nonces via `MotionConfig`.

## [11.0.8] 2024-02-29

### Fixed
Expand Down
38 changes: 28 additions & 10 deletions dev/benchmarks/cold-start-anime.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
}

.box {
width: 10px;
width: 10%;
height: 100px;
background-color: #fff;
}
</style>
</head>
<body>
<div class="container"></div>
<script src="../../node_modules/animejs/lib/anime.min.js"></script>
<script src="../../node_modules/animejs/lib/anime.js"></script>
<script>
// Create boxes
const numBoxes = 100
Expand All @@ -45,16 +45,34 @@
html += `<div><div class="box"></div></div>`
}
document.querySelector(".container").innerHTML = html
const boxes = document.querySelectorAll(".box")

setTimeout(() => {
anime({
targets: ".box",
rotate: 360,
backgroundColor: "#f00",
width: "100%",
duration: 1000,
easing: "linear",
})
// Cold start (read from DOM)
boxes.forEach((box) =>
anime({
targets: box,
rotate: Math.random() * 360,
backgroundColor: "#f00",
width: Math.random() * 100 + "%",
translateX: 5,
duration: 1000,
easing: "linear",
})
)

setTimeout(() => {
// Unit conversion
boxes.forEach((box) =>
anime({
targets: box,
width: Math.random() * 100 + "px",
translateX: "50%",
duration: 1000,
easing: "linear",
})
)
}, 1500)
}, 1000)
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions dev/benchmarks/cold-start-framer-motion.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
x: 5,
},
{
easing: "linear",
ease: "linear",
duration: 1,
}
)
Expand All @@ -78,7 +78,7 @@
x: "10%",
},
{
easing: "linear",
ease: "linear",
duration: 1,
}
)
Expand Down
55 changes: 43 additions & 12 deletions dev/benchmarks/cold-start-waapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,51 @@
html += `<div><div class="box"></div></div>`
}
document.querySelector(".container").innerHTML = html
const boxes = document.querySelectorAll(".box")

boxes.forEach((box) =>
box.animate(
{
rotate: "360deg",
backgroundColor: "#f00",
width: "100%",
},
{
duration: 1000,
fill: "forwards",
setTimeout(() => {
boxes.forEach((box) => {
const animation = box.animate(
{
rotate: Math.random() * 360 + "deg",
backgroundColor: "#f00",
width: Math.random() * 100 + "%",
translate: "5px 0",
},
{
duration: 1000,
fill: "both",
}
)
animation.onfinish = () => {
requestAnimationFrame(() => {
animation.commitStyles()
animation.cancel()
})
}
)
)
})

setTimeout(() => {
boxes.forEach((box) => {
const animation = box.animate(
{
width: Math.random() * 100 + "px",
translate: "50% 0",
},
{
duration: 1000,
fill: "both",
}
)
animation.onfinish = () => {
requestAnimationFrame(() => {
animation.commitStyles()
animation.cancel()
})
}
})
}, 1500)
}, 1000)
</script>
</body>
</html>
73 changes: 73 additions & 0 deletions dev/benchmarks/warm-start-framer-motion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<html>
<!--
Warm Start: Framer Motion
This benchmarks warm start - when an animation library already
knows the initial animating values.
Run in private browsing mode to avoid browser plugins interfering with
benchmark.
-->
<head>
<style>
body {
padding: 0;
margin: 0;
}

.container {
padding: 100px;
width: 100%;
display: flex;
flex-wrap: wrap;
}

.container > div {
width: 100px;
height: 100px;
}

.box {
width: 10%;
height: 100px;
background-color: #fff;
}
</style>
</head>
<body>
<div class="container"></div>

<script src="../../packages/framer-motion/dist/dom.js"></script>
<script>
// Create boxes
const numBoxes = 100
let html = ``
for (let i = 0; i < numBoxes; i++) {
html += `<div><div class="box"></div></div>`
}
document.querySelector(".container").innerHTML = html

const { animate } = Motion
const boxes = document.querySelectorAll(".box")

setTimeout(() => {
// Warm start
boxes.forEach((box) =>
animate(
box,
{
rotate: [0, Math.random() * 360],
backgroundColor: ["#fff", "#f00"],
width: ["0%", Math.random() * 100 + "%"],
x: [0, 5],
},
{
easing: "linear",
duration: 1,
}
)
)
}, 1000)
</script>
</body>
</html>
84 changes: 84 additions & 0 deletions dev/benchmarks/warm-start-gsap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<html>
<!--
Warm Start: GSAP
This benchmarks warm start - when an animation library already knows
the initial values to animate.
Run in private browsing mode to avoid browser plugins interfering with
benchmark.
-->
<head>
<style>
body {
padding: 0;
margin: 0;
}

.container {
padding: 100px;
width: 100%;
display: flex;
flex-wrap: wrap;
}

.container > div {
width: 100px;
height: 100px;
}

.box {
width: 10px;
height: 100px;
background-color: #fff;
}
</style>
</head>
<body>
<div class="container"></div>
<script src="../../node_modules/gsap/dist/gsap.min.js"></script>
<script>
// Create boxes
const numBoxes = 100
let html = ``
for (let i = 0; i < numBoxes; i++) {
html += `<div><div class="box"></div></div>`
}
document.querySelector(".container").innerHTML = html

const boxes = document.querySelectorAll(".box")

gsap.set(boxes, {
rotate: 0,
backgroundColor: "#fff",
width: "0%",
x: 0,
})

setTimeout(() => {
// Warm start
boxes.forEach((box) =>
gsap.to(box, {
rotate: Math.random() * 360,
backgroundColor: "#f00",
width: Math.random() * 100 + "%",
x: 5,
duration: 1,
})
)

// setTimeout(() => {
// // Unit conversion
// boxes.forEach((box) =>
// gsap.to(box, {
// width: Math.random() * 100 + "px",
// x: "50%",
// duration: 1,
// easing: "linear",
// })
// )
// }, 1500)
}, 1000)
</script>
</body>
</html>
Loading

0 comments on commit 9767415

Please sign in to comment.