@@ -8,17 +8,18 @@ import {
88} from "@lynx-js/react" ;
99import type { RefObject } from "@lynx-js/react" ;
1010import type { MainThread } from "@lynx-js/types" ;
11- import { feedbackScaleDuration } from "@seed-design/lynx-css/scale-feedback" with {
11+ import {
12+ feedbackScaleDuration ,
13+ feedbackScaleTimingFunction ,
14+ } from "@seed-design/lynx-css/scale-feedback" with {
1215 runtime : "shared" ,
1316} ;
1417
1518import type { LynxViewProps } from "../types" ;
1619import { calculateScaleFeedback , isReducedMotion } from "../utils/calculate-scale-feedback" with {
1720 runtime : "shared" ,
1821} ;
19- import { animateScaleFeedback , type ScaleFeedbackElement } from "../utils/animate-scale-feedback" with {
20- runtime : "shared" ,
21- } ;
22+ import type { ScaleFeedbackElement } from "../utils/animate-scale-feedback" ;
2223
2324type MainThreadLayoutChangeHandler = NonNullable < LynxViewProps [ "main-thread:bindlayoutchange" ] > ;
2425type MainThreadTouchHandler = NonNullable < LynxViewProps [ "main-thread:bindtouchstart" ] > ;
@@ -64,11 +65,24 @@ function runScaleFeedback(
6465) {
6566 "main thread" ;
6667
67- animationRef . current = animateScaleFeedback (
68- targetRef . current ,
69- animationRef . current ,
70- scale ,
71- duration ,
68+ const target = targetRef . current ;
69+ if ( ! target ) return ;
70+
71+ let currentTransform = "scale(1)" ;
72+ try {
73+ currentTransform = target . getComputedStyleProperty ( "transform" ) || currentTransform ;
74+ } catch {
75+ // Some non-native runtimes expose the method but cannot evaluate it.
76+ }
77+
78+ animationRef . current ?. cancel ( ) ;
79+ animationRef . current = target . animate (
80+ [ { transform : currentTransform } , { transform : `scale(${ scale } )` } ] ,
81+ {
82+ duration,
83+ easing : feedbackScaleTimingFunction ,
84+ fill : "forwards" ,
85+ } ,
7286 ) ;
7387}
7488
0 commit comments