@@ -8,17 +8,16 @@ 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 {
12- runtime : "shared" ,
13- } ;
11+ import {
12+ feedbackScaleDuration ,
13+ feedbackScaleTimingFunction ,
14+ } from "@seed-design/lynx-css/scale-feedback" with { runtime : "shared" } ;
1415
1516import type { LynxViewProps } from "../types" ;
1617import { calculateScaleFeedback , isReducedMotion } from "../utils/calculate-scale-feedback" with {
1718 runtime : "shared" ,
1819} ;
19- import { animateScaleFeedback , type ScaleFeedbackElement } from "../utils/animate-scale-feedback" with {
20- runtime : "shared" ,
21- } ;
20+ import type { ScaleFeedbackElement } from "../utils/animate-scale-feedback" ;
2221
2322type MainThreadLayoutChangeHandler = NonNullable < LynxViewProps [ "main-thread:bindlayoutchange" ] > ;
2423type MainThreadTouchHandler = NonNullable < LynxViewProps [ "main-thread:bindtouchstart" ] > ;
@@ -64,11 +63,24 @@ function runScaleFeedback(
6463) {
6564 "main thread" ;
6665
67- animationRef . current = animateScaleFeedback (
68- targetRef . current ,
69- animationRef . current ,
70- scale ,
71- duration ,
66+ const target = targetRef . current ;
67+ if ( ! target ) return ;
68+
69+ let currentTransform = "scale(1)" ;
70+ try {
71+ currentTransform = target . getComputedStyleProperty ( "transform" ) || currentTransform ;
72+ } catch {
73+ // Some non-native runtimes expose the method but cannot evaluate it.
74+ }
75+
76+ animationRef . current ?. cancel ( ) ;
77+ animationRef . current = target . animate (
78+ [ { transform : currentTransform } , { transform : `scale(${ scale } )` } ] ,
79+ {
80+ duration,
81+ easing : feedbackScaleTimingFunction ,
82+ fill : "forwards" ,
83+ } ,
7284 ) ;
7385}
7486
0 commit comments