From 462d1ad1ffec2089146e5ed9709f56b7af11dae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 11 Feb 2025 15:34:42 +0800 Subject: [PATCH] chore: more refs --- src/CSSMotion.tsx | 11 +++++++---- tests/StrictMode.spec.tsx | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/CSSMotion.tsx b/src/CSSMotion.tsx index f0c468c..d1243bd 100644 --- a/src/CSSMotion.tsx +++ b/src/CSSMotion.tsx @@ -18,7 +18,8 @@ import { getTransitionName, supportTransition } from './util/motion'; export interface CSSMotionRef { nativeElement: HTMLElement; - inMotion: () => boolean; + inMotion: boolean; + enableMotion: boolean; } export type CSSMotionConfig = @@ -172,9 +173,11 @@ export function genCSSMotion(config: CSSMotionConfig) { }, inMotion: { enumerable: true, - get: () => { - return () => getStatus() !== STATUS_NONE; - }, + get: () => getStatus() !== STATUS_NONE, + }, + enableMotion: { + enumerable: true, + get: () => supportMotion, }, }); return obj; diff --git a/tests/StrictMode.spec.tsx b/tests/StrictMode.spec.tsx index 10e955d..6ad2735 100644 --- a/tests/StrictMode.spec.tsx +++ b/tests/StrictMode.spec.tsx @@ -50,7 +50,7 @@ describe('StrictMode', () => { act(() => { jest.runAllTimers(); }); - expect(ref.current.inMotion()).toBeTruthy(); + expect(ref.current.inMotion).toBeTruthy(); expect(node).not.toHaveClass('transition-appear-start'); expect(node).toHaveClass('transition-appear-active'); @@ -58,7 +58,7 @@ describe('StrictMode', () => { fireEvent.transitionEnd(node); expect(node).not.toHaveClass('transition-appear'); - expect(ref.current.inMotion()).toBeFalsy(); + expect(ref.current.inMotion).toBeFalsy(); expect(ref.current.nativeElement).toBe(node); }); });