@@ -930,7 +930,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
930
930
931
931
if ( ( readingViewIs ( 'scroll' ) && ( _config . readingViewAdjustToWidth || _config . readingWebtoon ) ) && pageVisibilityIndex !== false )
932
932
{
933
- imgHeight = image . height ( ) + _config . readingMargin . top ;
933
+ imgHeight = largerImage . height + _config . readingMargin . top ;
934
934
935
935
if ( imgHeight > contentHeight )
936
936
{
@@ -1559,6 +1559,9 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1559
1559
haveZoom = true ;
1560
1560
}
1561
1561
1562
+ let withLimits = notCrossZoomLimits ( translateX , translateY , scale ) ;
1563
+ translateX = withLimits . x ;
1564
+
1562
1565
dom . this ( contentRight ) . find ( '.reading-body > div, .reading-lens > div > div' , true ) . css ( {
1563
1566
transition : 'transform ' + animationDurationS + 's, z-index ' + animationDurationS + 's' ,
1564
1567
transform : 'translateX(' + app . roundDPR ( translateX ) + 'px) translateY(' + app . roundDPR ( translateY ) + 'px) scale(' + scale + ')' ,
@@ -1601,6 +1604,8 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1601
1604
1602
1605
fixBlurOnZoom ( scale ) ;
1603
1606
1607
+ applyScaleST = false ;
1608
+
1604
1609
} , animationDurationS * 1000 + 100 ) ;
1605
1610
}
1606
1611
else
@@ -1645,6 +1650,11 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1645
1650
haveZoom = true ;
1646
1651
}
1647
1652
1653
+ let withLimits = notCrossZoomLimits ( translateX , translateY , scale ) ;
1654
+
1655
+ translateX = withLimits . x ;
1656
+ translateY = withLimits . y ;
1657
+
1648
1658
dom . this ( contentRight ) . find ( '.image-position' + currentZoomIndex , true ) . css ( {
1649
1659
transition : 'transform ' + animationDurationS + 's, z-index ' + animationDurationS + 's' ,
1650
1660
transform : 'translateX(' + app . roundDPR ( translateX ) + 'px) translateY(' + app . roundDPR ( translateY ) + 'px) scale(' + scale + ')' ,
@@ -1663,11 +1673,21 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1663
1673
1664
1674
fixBlurOnZoom ( scale , currentZoomIndex ) ;
1665
1675
1676
+ applyScaleST = false ;
1677
+
1666
1678
} , animationDurationS * 1000 + 100 ) ;
1667
1679
}
1668
1680
1669
- zoomMoveData . x = currentPageXY . x ;
1670
- zoomMoveData . y = currentPageXY . y ;
1681
+ if ( center )
1682
+ {
1683
+ zoomMoveData . x = ( originalRect . left + originalRect . width / 2 ) - ( translateX / scale ) ;
1684
+ zoomMoveData . y = ( originalRect . top + originalRect . height / 2 ) - ( translateY / scale ) ;
1685
+ }
1686
+ else
1687
+ {
1688
+ zoomMoveData . x = currentPageXY . x ;
1689
+ zoomMoveData . y = currentPageXY . y ;
1690
+ }
1671
1691
1672
1692
scalePrevData = {
1673
1693
tranX : translateX ,
@@ -1813,20 +1833,65 @@ function fixBlurOnZoom(scale = 1, index = false)
1813
1833
1814
1834
}
1815
1835
1816
- // Drag zoom
1817
- function dragZoom ( x , y )
1836
+ function getIndexImagesSize ( index )
1837
+ {
1838
+ let contentRight = template . _contentRight ( ) ;
1839
+
1840
+ let width = 0 ;
1841
+ let height = 0 ;
1842
+
1843
+ let images = contentRight . querySelectorAll ( '.reading-body .image-position' + index + ' .r-img > *' ) ;
1844
+
1845
+ let len = images . length ;
1846
+
1847
+ if ( len == 1 )
1848
+ width += _config . readingMargin . left * 2 ;
1849
+
1850
+ for ( let i = 0 ; i < len ; i ++ )
1851
+ {
1852
+ let img = images [ i ] ;
1853
+
1854
+ width += + img . dataset . width ;
1855
+
1856
+ if ( i > 0 )
1857
+ {
1858
+ if ( i == 1 )
1859
+ width += + img . dataset . left * 3 ;
1860
+ else
1861
+ width += + img . dataset . left ;
1862
+ }
1863
+
1864
+ let _height = + img . dataset . height + ( _config . readingMargin . top * 2 ) ;
1865
+
1866
+ if ( _height > height ) height = _height ;
1867
+ }
1868
+
1869
+ return {
1870
+ width : width ,
1871
+ height : height ,
1872
+ } ;
1873
+ }
1874
+
1875
+ function notCrossZoomLimits ( x , y , scale = false )
1818
1876
{
1819
- x = scalePrevData . tranX2 + x ;
1820
- y = scalePrevData . tranY2 + y ;
1877
+ scale = scale !== false ? scale : scalePrevData . scale ;
1878
+
1879
+ let indexSize = getIndexImagesSize ( ( config . readingGlobalZoom && readingViewIs ( 'scroll' ) ) ? ( currentIndex - 1 ) : currentZoomIndex ) ;
1821
1880
1822
- let maxX = originalRect . width * 0.5 * scalePrevData . scale - originalRect . width * 0.5 ;
1823
- let minX = originalRect . width * - 0.5 * scalePrevData . scale - originalRect . width * - 0.5 ;
1881
+ let maxX = indexSize . width * 0.5 * scale - originalRect . width * 0.5 ;
1882
+ let minX = indexSize . width * - 0.5 * scale - originalRect . width * - 0.5 ;
1883
+
1884
+ if ( maxX < 0 ) maxX = 0 ;
1885
+ if ( minX > 0 ) minX = 0 ;
1824
1886
1825
1887
let maxDiff = readingViewIs ( 'scroll' ) ? ( ( originalRect . top + originalRect . height ) - ( originalRectReadingBody . top + originalRectReadingBody . height ) ) : 0 ;
1826
1888
let minDiff = readingViewIs ( 'scroll' ) ? ( originalRect . top - originalRectReadingBody . top ) : 0 ;
1827
1889
1828
- let maxY = ( originalRect . height * 0.5 * scalePrevData . scale - originalRect . height * 0.5 ) - ( minDiff < 0 ? minDiff : 0 ) ;
1829
- let minY = ( originalRect . height * - 0.5 * scalePrevData . scale - originalRect . height * - 0.5 ) - ( maxDiff > 0 ? maxDiff + _config . readingMargin . top : 0 ) ;
1890
+ let maxY = ( indexSize . height * 0.5 * scale - originalRect . height * 0.5 ) - ( minDiff < 0 ? minDiff : 0 ) ;
1891
+ let minY = ( indexSize . height * - 0.5 * scale - originalRect . height * - 0.5 ) - ( maxDiff > 0 ? maxDiff + _config . readingMargin . top : 0 ) ;
1892
+
1893
+ if ( maxY < 0 ) maxY = 0 ;
1894
+ if ( minY > 0 ) minY = 0 ;
1830
1895
1831
1896
if ( x > maxX )
1832
1897
x = maxX ;
@@ -1838,6 +1903,17 @@ function dragZoom(x, y)
1838
1903
else if ( y < minY )
1839
1904
y = minY ;
1840
1905
1906
+ return { x : x , y : y , maxX : maxX , maxY : maxY } ;
1907
+ }
1908
+
1909
+ // Drag zoom
1910
+ function dragZoom ( x , y )
1911
+ {
1912
+ let withLimits = notCrossZoomLimits ( scalePrevData . tranX2 + x , scalePrevData . tranY2 + y ) ;
1913
+
1914
+ x = withLimits . x ;
1915
+ y = withLimits . y ;
1916
+
1841
1917
let contentRight = template . _contentRight ( ) ;
1842
1918
1843
1919
if ( config . readingGlobalZoom && readingViewIs ( 'scroll' ) )
@@ -2102,6 +2178,14 @@ function magnifyingGlassControl(mode, e = false, lensData = false)
2102
2178
2103
2179
function resizedWindow ( )
2104
2180
{
2181
+ originalRect = false ;
2182
+ originalRectReadingBody = false ;
2183
+ originalRect2 = false ;
2184
+ originalRectReadingBody2 = false ;
2185
+ contentLeftRect = false ;
2186
+ contentRightRect = false ;
2187
+ barHeaderRect = false ;
2188
+
2105
2189
if ( onReading || _onReading )
2106
2190
{
2107
2191
disposeImages ( ) ;
@@ -3175,13 +3259,15 @@ function mousemove(event)
3175
3259
{
3176
3260
event . preventDefault ( ) ;
3177
3261
3178
- let _pageX = pageX - contentRightRect . left ;
3179
- let _pageY = pageY - contentRightRect . top ;
3262
+ let withLimits = notCrossZoomLimits ( 0 , 0 ) ;
3263
+
3264
+ let widthM = contentRightRect . width / 2 ;
3265
+ let heightM = contentRightRect . height / 2 ;
3180
3266
3181
- let x = - ( _pageX - contentRightRect . width / 2 ) * ( scalePrevData . scale - 1 ) ;
3182
- let y = - ( _pageY - contentRightRect . height / 2 ) * ( scalePrevData . scale - 1 ) ;
3267
+ let x = - ( pageX - zoomMoveData . x ) * ( withLimits . maxX / widthM * 1.2 ) ;
3268
+ let y = - ( pageY - zoomMoveData . y ) * ( withLimits . maxY / heightM * 1.2 ) ;
3183
3269
3184
- dragZoom ( x - scalePrevData . tranX2 , y - scalePrevData . tranY2 ) ;
3270
+ dragZoom ( x , y ) ;
3185
3271
3186
3272
scalePrevData . tranX = zoomMoveData . tranX ;
3187
3273
scalePrevData . tranY = zoomMoveData . tranY ;
0 commit comments