@@ -21,7 +21,11 @@ interface RenderApp {
2121 pan : ( options : { x : number ; y : number ; steps ?: number } ) => void ;
2222 touchPan : ( options : { x : number ; y : number ; steps ?: number } ) => void ;
2323 zoom : ( options : { value : number ; center ?: [ number , number ] } ) => void ;
24- pinch : ( options : { value : number ; center ?: [ number , number ] } ) => void ;
24+ pinch : ( options : {
25+ value : number ;
26+ center ?: [ number , number ] ;
27+ targetCenter ?: [ number , number ] ;
28+ } ) => void ;
2529}
2630
2731const waitForPreviousActionToEnd = ( ) => {
@@ -42,10 +46,10 @@ function getPinchTouches(
4246 const dx = ( step + from ) / 2 ;
4347
4448 const leftTouch = {
45- pageX : 0 - dx ,
46- pageY : 0 - dx ,
47- clientX : 0 - dx ,
48- clientY : 0 - dx ,
49+ pageX : cx - dx ,
50+ pageY : cy - dx ,
51+ clientX : cx - dx ,
52+ clientY : cy - dx ,
4953 target : content ,
5054 } ;
5155
@@ -85,6 +89,9 @@ export const renderApp = ({
8589 doubleClick : {
8690 disabled : true ,
8791 } ,
92+ velocityAnimation : {
93+ disabled : true ,
94+ } ,
8895 autoAlignment : {
8996 disabled : true ,
9097 } ,
@@ -155,15 +162,15 @@ export const renderApp = ({
155162
156163 waitForPreviousActionToEnd ( ) ;
157164
165+ const targetCenter = options ?. targetCenter || center ;
158166 const isZoomIn = ref . current . instance . state . scale < value ;
159167 const from = isZoomIn ? 1 : 2 ;
160168 const step = 0.1 ;
161169
162170 let pinchValue = 0 ;
163- let touches = getPinchTouches ( content , center , step , from ) ;
164171
165172 fireEvent . touchStart ( content , {
166- touches,
173+ touches : getPinchTouches ( content , center , step , from ) ,
167174 } ) ;
168175
169176 const startTime = Date . now ( ) ;
@@ -182,18 +189,21 @@ export const renderApp = ({
182189 const newStep = isNearScale ? step / 6 : step ;
183190
184191 pinchValue = pinchValue + newStep ;
185- touches = getPinchTouches ( content , center , pinchValue , from ) ;
186192
187193 fireEvent . touchMove ( content , {
188- touches,
194+ touches : getPinchTouches ( content , center , pinchValue , from ) ,
189195 } ) ;
190196 } else {
191197 break ;
192198 }
193199 }
194200
201+ fireEvent . touchMove ( content , {
202+ touches : getPinchTouches ( content , targetCenter , pinchValue , from ) ,
203+ } ) ;
204+
195205 fireEvent . touchEnd ( content , {
196- touches,
206+ touches : getPinchTouches ( content , center , pinchValue , from ) ,
197207 } ) ;
198208 } ;
199209
0 commit comments