Skip to content

Commit 8ed12f4

Browse files
committed
Refactor
1 parent 817b45e commit 8ed12f4

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/hooks/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const createHandle = () => {
7474
_commit: (
7575
animation: Animation | undefined,
7676
el: HTMLElement,
77-
getKeys: () => string[]
77+
keyframes: TypedKeyframe[]
7878
) => {
7979
if (!animation) return;
8080
if (animation.commitStyles) {
@@ -83,7 +83,7 @@ export const createHandle = () => {
8383
}
8484
// Fallback for commitStyles
8585
const computedStyle = getComputedStyle(el);
86-
getKeys().forEach((k) => {
86+
getKeyframeKeys(keyframes).forEach((k) => {
8787
(el.style as any)[k] = (computedStyle as any)[k];
8888
});
8989
},

src/hooks/useAnimation.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
AnimationOptions,
55
createAnimation,
66
createHandle,
7-
getKeyframeKeys,
87
TypedKeyframe,
98
} from "./core";
109

@@ -96,9 +95,7 @@ export const useAnimation = (
9695
return externalHandle;
9796
},
9897
commit: () => {
99-
handle._commit(getAnimation(), getTarget()!, () =>
100-
getKeyframeKeys(getKeyframes())
101-
);
98+
handle._commit(getAnimation(), getTarget()!, getKeyframes());
10299
return externalHandle;
103100
},
104101
setTime: (time) => {

src/hooks/useAnimations.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
AnimationOptions,
55
createAnimation,
66
createHandle,
7-
getKeyframeKeys,
87
TypedKeyframe,
98
} from "./core";
109
import type { WithRef } from "./useAnimation";
@@ -98,8 +97,10 @@ export const useAnimations = <ID extends string>(
9897
return externalHandle;
9998
},
10099
commit: (name) => {
101-
handle._commit(getAnimation(name), getTarget()!, () =>
102-
getKeyframeKeys(toArray(getKeyframesAndOptions(name)[0]))
100+
handle._commit(
101+
getAnimation(name),
102+
getTarget()!,
103+
toArray(getKeyframesAndOptions(name)[0])
103104
);
104105
return externalHandle;
105106
},

0 commit comments

Comments
 (0)