-
-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating * Updating test * Fixing ssr will-change * fixing tests * Updating size limits
- Loading branch information
1 parent
f41b701
commit dc9d6b3
Showing
6 changed files
with
21 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 7 additions & 15 deletions
22
packages/framer-motion/src/value/use-will-change/add-will-change.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
import { WillChangeMotionValue } from "./WillChangeMotionValue" | ||
import type { VisualElement } from "../../render/VisualElement" | ||
import { isWillChangeMotionValue } from "./is" | ||
import { getWillChangeName } from "./get-will-change-name" | ||
|
||
export function addValueToWillChange( | ||
visualElement: VisualElement, | ||
key: string | ||
) { | ||
if (!visualElement.applyWillChange) return | ||
|
||
let willChange = visualElement.getValue("willChange") | ||
const willChange = visualElement.getValue("willChange") | ||
|
||
/** | ||
* If we haven't created a willChange MotionValue, and the we haven't been | ||
* manually provided one, create one. | ||
*/ | ||
if (!willChange && !visualElement.props.style?.willChange) { | ||
willChange = new WillChangeMotionValue("auto") | ||
visualElement.addValue("willChange", willChange) | ||
} | ||
|
||
/** | ||
* It could be that a user has set willChange to a regular MotionValue, | ||
* in which case we can't add the value to it. | ||
*/ | ||
if (isWillChangeMotionValue(willChange)) { | ||
return willChange.add(key) | ||
} else if ( | ||
!visualElement.props.style?.willChange && | ||
getWillChangeName(key) | ||
) { | ||
visualElement.setStaticValue("willChange", "transform") | ||
} | ||
} |