@@ -2447,35 +2447,33 @@ function resetZoom(animation = true, index = false, apply = true, center = true,
24472447// Fix blur on zoom cause by tranform scale, still happening in vertical reader in some conditions
24482448function fixBlurOnZoom ( scale = 1 , index = false )
24492449{
2450- let _scale = 1 / scale ;
2450+ const _scale = 1 / scale ;
24512451
2452- let contentRight = template . _contentRight ( ) ;
2453- let images = index !== false ? contentRight . querySelectorAll ( '.image-position' + index + ' oc-img img, .image-position' + index + ' oc-img canvas' ) : contentRight . querySelectorAll ( '.r-img oc-img img, .r-img oc-img canvas ' ) ;
2452+ const contentRight = template . _contentRight ( ) ;
2453+ const images = index !== false ? contentRight . querySelectorAll ( '.image-position' + index + ' oc-img img' ) : contentRight . querySelectorAll ( '.r-img oc-img img' ) ;
24542454
24552455 for ( let i = 0 , len = images . length ; i < len ; i ++ )
24562456 {
2457- let img = images [ i ] ;
2458- let image = imagesData [ + img . dataset . index ] || [ ] ;
2457+ const img = images [ i ] ;
2458+ const image = imagesData [ + img . dataset . index ] || [ ] ;
24592459
2460- let ocImg = img . parentElement ;
2460+ const ocImg = img . parentElement ;
24612461
2462- if ( img . tagName != 'CANVAS' )
2463- {
2464- let width = ( image ?. rotated == 1 || image ?. rotated == 2 ) ? + ocImg . dataset . height : + ocImg . dataset . width ;
2465- let height = ( image ?. rotated == 1 || image ?. rotated == 2 ) ? + ocImg . dataset . width : + ocImg . dataset . height ;
2462+ let width , height ;
24662463
2467- let _width = Math . round ( width * scale * window . devicePixelRatio ) ;
2468- let _height = Math . round ( height * scale * window . devicePixelRatio ) ;
2464+ width = + ocImg . dataset . width ;
2465+ height = + ocImg . dataset . height ;
24692466
2470- img . style . width = ( _width / window . devicePixelRatio ) + 'px' ;
2471- img . style . height = ( _height / window . devicePixelRatio ) + 'px' ;
2472- }
2467+ width = Math . round ( width * scale * window . devicePixelRatio ) ;
2468+ height = Math . round ( height * scale * window . devicePixelRatio ) ;
2469+
2470+ width = ( image ?. rotated == 1 || image ?. rotated == 2 ) ? height : width ;
2471+ height = ( image ?. rotated == 1 || image ?. rotated == 2 ) ? width : height ;
24732472
2474- console . log ( 'scale(' + _scale + ') ' + rotateImage ( image ?. rotated , 0.001 , 0.001 ) ) ;
2473+ img . style . width = ( width / window . devicePixelRatio ) + 'px' ;
2474+ img . style . height = ( height / window . devicePixelRatio ) + 'px' ;
24752475
2476- if ( img . tagName == 'CANVAS' )
2477- img . style . transform = 'scale(' + ( _scale / window . devicePixelRatio ) + ') ' + rotateImage ( image ?. rotated , 0.001 , 0.001 ) ;
2478- else if ( img . classList . contains ( 'blobRender' ) || img . classList . contains ( 'zoomOriginalSize' ) || img . classList . contains ( 'originalSize' ) )
2476+ if ( img . classList . contains ( 'blobRender' ) || img . classList . contains ( 'zoomOriginalSize' ) || img . classList . contains ( 'originalSize' ) )
24792477 img . style . transform = 'scale(' + _scale + ') ' + rotateImage ( image ?. rotated , 0.001 , 0.001 ) ;
24802478 else
24812479 img . style . transform = 'scale(' + _scale + ') ' + rotateImage ( image ?. rotated ) ;
@@ -2490,21 +2488,18 @@ function fixBlurOnZoom(scale = 1, index = false)
24902488
24912489 for ( let i = 0 , len = images . length ; i < len ; i ++ )
24922490 {
2493- let img = images [ i ] ;
2494- let image = imagesData [ + img . dataset . index ] || [ ] ;
2491+ const img = images [ i ] ;
2492+ const image = imagesData [ + img . dataset . index ] || [ ] ;
24952493
2496- if ( img . tagName != 'CANVAS' && ! img . classList . contains ( 'blobRender' ) && ! img . classList . contains ( 'zoomOriginalSize' ) && ! img . classList . contains ( 'originalSize' ) )
2497- {
2498- let rect = img . getBoundingClientRect ( ) ;
2494+ const rect = img . getBoundingClientRect ( ) ;
24992495
2500- let left = - ( rect . left - app . floorDPR ( rect . left ) ) ;
2501- let top = - ( rect . top - app . floorDPR ( rect . top ) ) ;
2496+ let left = - ( rect . left - app . floorDPR ( rect . left ) ) ;
2497+ let top = - ( rect . top - app . floorDPR ( rect . top ) ) ;
25022498
2503- if ( left < - 0.5 ) left ++ ;
2504- if ( top < - 0.5 ) top ++ ;
2499+ if ( left < - 0.5 ) left ++ ;
2500+ if ( top < - 0.5 ) top ++ ;
25052501
2506- img . style . transform = 'scale(' + _scale + ') ' + rotateImage ( image ?. rotated , left , top ) ;
2507- }
2502+ img . style . transform = 'scale(' + _scale + ') ' + rotateImage ( image ?. rotated , left , top ) ;
25082503 }
25092504
25102505 } ) ;
0 commit comments