@@ -23,6 +23,9 @@ interface PossibleCords {
23
23
maxX : number ;
24
24
maxY : number ;
25
25
}
26
+
27
+ const ZOOM_TRANSITION_DURATION = 500 ;
28
+
26
29
export default class Zoom {
27
30
private core : LightGallery ;
28
31
private settings : ZoomSettings ;
@@ -279,11 +282,7 @@ export default class Zoom {
279
282
this . top = y ;
280
283
281
284
if ( resetToMax ) {
282
- const actualSizeScale = this . getCurrentImageActualSizeScale ( ) ;
283
-
284
- if ( scale >= actualSizeScale ) {
285
- this . setZoomImageSize ( ) ;
286
- }
285
+ this . setZoomImageSize ( ) ;
287
286
}
288
287
}
289
288
@@ -310,30 +309,47 @@ export default class Zoom {
310
309
. first ( ) ;
311
310
312
311
setTimeout ( ( ) => {
313
- $image . addClass ( 'no-transition' ) ;
314
- this . imageReset = true ;
315
- } , 500 ) ;
312
+ const actualSizeScale = this . getCurrentImageActualSizeScale ( ) ;
313
+
314
+ if ( this . scale >= actualSizeScale ) {
315
+ $image . addClass ( 'no-transition' ) ;
316
+ this . imageReset = true ;
317
+ }
318
+ } , ZOOM_TRANSITION_DURATION ) ;
319
+
316
320
setTimeout ( ( ) => {
317
- const dragAllowedAxises = this . getDragAllowedAxises ( this . scale ) ;
318
-
319
- $image
320
- . css (
321
- 'width' ,
322
- ( $image . get ( ) as HTMLImageElement ) . naturalWidth + 'px' ,
323
- )
324
- . css (
325
- 'height' ,
326
- ( $image . get ( ) as HTMLImageElement ) . naturalHeight + 'px' ,
327
- ) ;
328
- this . core . outer . addClass ( 'lg-actual-size' ) ;
329
- if ( dragAllowedAxises . allowX && dragAllowedAxises . allowY ) {
330
- $image . addClass ( 'reset-transition' ) ;
331
- } else if ( dragAllowedAxises . allowX && ! dragAllowedAxises . allowY ) {
332
- $image . addClass ( 'reset-transition-x' ) ;
333
- } else if ( ! dragAllowedAxises . allowX && dragAllowedAxises . allowY ) {
334
- $image . addClass ( 'reset-transition-y' ) ;
321
+ const actualSizeScale = this . getCurrentImageActualSizeScale ( ) ;
322
+
323
+ if ( this . scale >= actualSizeScale ) {
324
+ const dragAllowedAxises = this . getDragAllowedAxises ( this . scale ) ;
325
+
326
+ $image
327
+ . css (
328
+ 'width' ,
329
+ ( $image . get ( ) as HTMLImageElement ) . naturalWidth + 'px' ,
330
+ )
331
+ . css (
332
+ 'height' ,
333
+ ( $image . get ( ) as HTMLImageElement ) . naturalHeight + 'px' ,
334
+ ) ;
335
+
336
+ this . core . outer . addClass ( 'lg-actual-size' ) ;
337
+
338
+ if ( dragAllowedAxises . allowX && dragAllowedAxises . allowY ) {
339
+ $image . addClass ( 'reset-transition' ) ;
340
+ } else if (
341
+ dragAllowedAxises . allowX &&
342
+ ! dragAllowedAxises . allowY
343
+ ) {
344
+ $image . addClass ( 'reset-transition-x' ) ;
345
+ } else if (
346
+ ! dragAllowedAxises . allowX &&
347
+ dragAllowedAxises . allowY
348
+ ) {
349
+ $image . addClass ( 'reset-transition-y' ) ;
350
+ }
335
351
}
336
- } , 550 ) ;
352
+ } , ZOOM_TRANSITION_DURATION + 50 ) ;
337
353
}
338
354
339
355
/**
0 commit comments