Skip to content

Commit

Permalink
Fixing restore CSS vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Mar 15, 2023
1 parent 7531411 commit 2f1dac7
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function getVariableValue(
export function resolveCSSVariables(
visualElement: VisualElement,
{ ...target }: TargetWithKeyframes,
transitionEnd: Target | undefined
transitionEnd: Target
): { target: TargetWithKeyframes; transitionEnd?: Target } {
const element = visualElement.current
if (!(element instanceof Element)) return { target, transitionEnd }
Expand Down Expand Up @@ -91,10 +91,12 @@ export function resolveCSSVariables(
// Clone target if it hasn't already been
target[key] = resolved

if (!transitionEnd) transitionEnd = {}

// If the user hasn't already set this key on `transitionEnd`, set it to the unresolved
// CSS variable. This will ensure that after the animation the component will reflect
// changes in the value of the CSS variable.
if (transitionEnd && transitionEnd[key] === undefined) {
if (transitionEnd[key] === undefined) {
transitionEnd[key] = current
}
}
Expand Down

0 comments on commit 2f1dac7

Please sign in to comment.