Skip to content

Commit

Permalink
Merge pull request #2227 from framer/fix/custom-value
Browse files Browse the repository at this point in the history
Transform newly-read values
  • Loading branch information
mergetron[bot] authored Jul 14, 2023
2 parents bb3fa04 + 48aa31b commit df700d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion packages/framer-motion/src/render/dom/DOMVisualElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ export abstract class DOMVisualElement<
}

if (isMounted) {
checkTargetForNewValues(this, target, origin as any)
const newValues = checkTargetForNewValues(
this,
target,
origin as any
)

// If new values have been added, for instance named color values, transform these
if (transformValues && newValues) {
origin = transformValues(origin as any)
}

const parsed = parseDomVariant(this, target, origin, transitionEnd)
transitionEnd = parsed.transitionEnd
target = parsed.target
Expand Down
6 changes: 4 additions & 2 deletions packages/framer-motion/src/render/utils/setters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ export function checkTargetForNewValues(
visualElement: VisualElement,
target: TargetWithKeyframes,
origin: ResolvedValues
) {
): boolean {
const newValueKeys = Object.keys(target).filter(
(key) => !visualElement.hasValue(key)
)

const numNewValues = newValueKeys.length

if (!numNewValues) return
if (!numNewValues) return false

for (let i = 0; i < numNewValues; i++) {
const key = newValueKeys[i]
Expand Down Expand Up @@ -140,6 +140,8 @@ export function checkTargetForNewValues(
}
if (value !== null) visualElement.setBaseTarget(key, value)
}

return true
}

export function getOriginFromTransition(key: string, transition: Transition) {
Expand Down

0 comments on commit df700d2

Please sign in to comment.