@@ -158,32 +158,34 @@ class GestureViewerManager {
158158 rotate = ( angle : 0 | 90 | 180 | 270 | 360 = 90 , clockwise = true ) => {
159159 const MAX_ANGLE = 360 ;
160160
161+ const currentRotation = this . rotation ?. get ( ) ;
162+
161163 if (
162- ! this . rotation ||
164+ currentRotation === undefined ||
163165 angle < 0 ||
164166 angle > MAX_ANGLE ||
165- ( angle !== 0 && this . rotation . value % angle !== 0 && angle !== 360 )
167+ ( angle !== 0 && currentRotation % angle !== 0 && angle !== 360 )
166168 ) {
167169 return ;
168170 }
169171
170172 if ( angle === 0 ) {
171- const nextAngle = Math . floor ( this . rotation . value / MAX_ANGLE ) * MAX_ANGLE ;
173+ const nextAngle = Math . floor ( currentRotation / MAX_ANGLE ) * MAX_ANGLE ;
172174
173- this . rotation . value = withTiming ( clockwise ? nextAngle : nextAngle - MAX_ANGLE ) ;
175+ this . rotation ?. set ( withTiming ( clockwise ? nextAngle : nextAngle - MAX_ANGLE ) ) ;
174176 return ;
175177 }
176178
177179 if ( angle === 360 ) {
178- this . rotation . value = withTiming (
179- clockwise ? this . rotation . value + MAX_ANGLE : this . rotation . value - MAX_ANGLE ,
180+ this . rotation ?. set (
181+ withTiming ( clockwise ? currentRotation + MAX_ANGLE : currentRotation - MAX_ANGLE ) ,
180182 ) ;
181183 return ;
182184 }
183185
184- const nextAngle = clockwise ? this . rotation . value + angle : this . rotation . value - angle ;
186+ const nextAngle = clockwise ? currentRotation + angle : currentRotation - angle ;
185187
186- this . rotation . value = withTiming ( nextAngle ) ;
188+ this . rotation ?. set ( withTiming ( nextAngle ) ) ;
187189 } ;
188190
189191 zoomIn = ( multiplier = 0.25 ) => {
@@ -197,21 +199,21 @@ class GestureViewerManager {
197199 return ;
198200 }
199201
200- const nextScale = Math . min ( this . scale . value * ( 1 + multiplier ) , this . maxZoomScale ) ;
202+ const nextScale = Math . min ( this . scale . get ( ) * ( 1 + multiplier ) , this . maxZoomScale ) ;
201203
202- this . scale . value = withTiming ( nextScale ) ;
204+ this . scale . set ( withTiming ( nextScale ) ) ;
203205
204206 const { translateX, translateY } = createBoundsConstraint ( {
205207 width : this . width ,
206208 height : this . height ,
207209 } ) ( {
208- translateX : this . translateX . value ,
209- translateY : this . translateY . value ,
210+ translateX : this . translateX . get ( ) ,
211+ translateY : this . translateY . get ( ) ,
210212 scale : nextScale ,
211213 } ) ;
212214
213- this . translateX . value = withTiming ( translateX ) ;
214- this . translateY . value = withTiming ( translateY ) ;
215+ this . translateX . set ( withTiming ( translateX ) ) ;
216+ this . translateY . set ( withTiming ( translateY ) ) ;
215217 } ;
216218
217219 zoomOut = ( multiplier = 0.25 ) => {
@@ -225,27 +227,27 @@ class GestureViewerManager {
225227 return ;
226228 }
227229
228- const nextScale = Math . max ( this . scale . value / ( 1 + multiplier ) , 1 ) ;
230+ const nextScale = Math . max ( this . scale . get ( ) / ( 1 + multiplier ) , 1 ) ;
229231
230- this . scale . value = withTiming ( nextScale ) ;
232+ this . scale . set ( withTiming ( nextScale ) ) ;
231233
232234 if ( nextScale === 1 ) {
233- this . translateX . value = withTiming ( 0 ) ;
234- this . translateY . value = withTiming ( 0 ) ;
235+ this . translateX . set ( withTiming ( 0 ) ) ;
236+ this . translateY . set ( withTiming ( 0 ) ) ;
235237 return ;
236238 }
237239
238240 const { translateX, translateY } = createBoundsConstraint ( {
239241 width : this . width ,
240242 height : this . height ,
241243 } ) ( {
242- translateX : this . translateX . value ,
243- translateY : this . translateY . value ,
244+ translateX : this . translateX . get ( ) ,
245+ translateY : this . translateY . get ( ) ,
244246 scale : nextScale ,
245247 } ) ;
246248
247- this . translateX . value = withTiming ( translateX ) ;
248- this . translateY . value = withTiming ( translateY ) ;
249+ this . translateX . set ( withTiming ( translateX ) ) ;
250+ this . translateY . set ( withTiming ( translateY ) ) ;
249251 } ;
250252
251253 resetZoom = ( scale = 1 ) => {
@@ -259,9 +261,9 @@ class GestureViewerManager {
259261 return ;
260262 }
261263
262- this . scale . value = withTiming ( scale ) ;
263- this . translateX . value = withTiming ( 0 ) ;
264- this . translateY . value = withTiming ( 0 ) ;
264+ this . scale . set ( withTiming ( scale ) ) ;
265+ this . translateX . set ( withTiming ( 0 ) ) ;
266+ this . translateY . set ( withTiming ( 0 ) ) ;
265267 } ;
266268
267269 goToIndex = ( index : number ) => {
0 commit comments