@@ -706,6 +706,8 @@ function changeHeaderButtons(scrollInStart = null, scrollInEnd = null)
706
706
//Go to a specific comic image (Left menu)
707
707
function goToImageCL ( index , animation = true , fromScroll = false )
708
708
{
709
+ if ( ! onReading ) return ;
710
+
709
711
render . focusIndex ( index ) ;
710
712
filters . focusIndex ( index ) ;
711
713
@@ -1436,7 +1438,7 @@ function showPreviousComic(mode, animation = true, invert = false)
1436
1438
}
1437
1439
}
1438
1440
1439
- var currentScale = 1 , scalePrevData = { tranX : 0 , tranX2 : 0 , tranY : 0 , tranY2 : 0 , scale : 1 , scrollTop : 0 } , originalRect = false , originalRectReadingBody = false , haveZoom = false , currentZoomIndex = false , applyScaleST = false , zoomingIn = false , prevAnime = false ;
1441
+ var currentScale = 1 , scalePrevData = { tranX : 0 , tranX2 : 0 , tranY : 0 , tranY2 : 0 , scale : 1 , scrollTop : 0 } , originalRect = false , originalRectReadingBody = false , originalRect2 = false , originalRectReadingBody2 = false , haveZoom = false , currentZoomIndex = false , applyScaleST = false , zoomingIn = false , prevAnime = false ;
1440
1442
1441
1443
function applyScaleScrollAndHeight ( )
1442
1444
{
@@ -1457,7 +1459,7 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1457
1459
}
1458
1460
else
1459
1461
{
1460
- var currentRect = template . contentRight ( '.image-position' + ( currentIndex - 1 ) ) . get ( 0 ) . getBoundingClientRect ( ) ;
1462
+ let currentRect = template . contentRight ( '.image-position' + ( currentIndex - 1 ) ) . get ( 0 ) . getBoundingClientRect ( ) ;
1461
1463
1462
1464
if ( currentRect . top > currentPageXY . y && ( currentIndex - 2 ) >= 0 )
1463
1465
{
@@ -1483,8 +1485,10 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1483
1485
else
1484
1486
template . barHeader ( '.button-reset-zoom' ) . attr ( 'hover-text' , language . menu . view . resetZoom ) . html ( 'zoom_out_map' ) ;
1485
1487
1486
- let content = template . contentRight ( ) . children ( ) ;
1487
- content . stop ( true ) ;
1488
+ let contentRight = template . _contentRight ( ) ;
1489
+
1490
+ let content = contentRight . firstElementChild ;
1491
+ $ ( content ) . stop ( true ) ;
1488
1492
1489
1493
clearTimeout ( applyScaleST ) ;
1490
1494
@@ -1495,81 +1499,98 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1495
1499
1496
1500
if ( originalRect === false )
1497
1501
{
1498
- originalRect = template . contentRight ( '.reading-body' ) . get ( 0 ) . getBoundingClientRect ( ) ;
1499
- originalRectReadingBody = template . contentRight ( ) . children ( ) . get ( 0 ) . getBoundingClientRect ( ) ;
1502
+ originalRect = originalRect2 = contentRight . querySelector ( '.reading-body' ) . getBoundingClientRect ( ) ;
1503
+ originalRectReadingBody = content . getBoundingClientRect ( ) ;
1500
1504
}
1505
+ else if ( originalRect2 === false )
1506
+ {
1507
+ originalRect2 = contentRight . querySelector ( '.reading-body' ) . getBoundingClientRect ( ) ;
1508
+ }
1509
+
1510
+ scrollTop = content . scrollTop ;
1511
+ scrollHeight = content . scrollHeight ;
1501
1512
1502
- scrollTop = content . scrollTop ( ) ;
1513
+ let _scale = scalePrevData . _scale ? scale / scalePrevData . _scale : scale ;
1503
1514
1504
- let pageX = currentPageXY . x - originalRect . left ;
1505
- let pageY = currentPageXY . y + scrollTop - originalRectReadingBody . top ;
1515
+ let scaleOffset = 1 / scale ;
1506
1516
1507
- let addX = ( 0.5 - ( pageX / originalRect . width ) ) * originalRect . width ;
1508
- let addY = ( 0.5 - ( pageY / originalRect . height ) ) * originalRect . height ;
1517
+ let pageX = currentPageXY . x - originalRect2 . left ;
1518
+ let pageY = currentPageXY . y - originalRectReadingBody . top ;
1519
+
1520
+ let addX = ( 0.5 - ( pageX / originalRect2 . width ) ) * originalRect2 . width ;
1521
+ let addY = pageY ;
1509
1522
1510
1523
if ( center )
1511
1524
{
1512
1525
addX = 0 ;
1513
- addY = ( originalRect . height / 2 - originalRectReadingBody . height / 2 ) - scrollTop ;
1514
-
1515
- //if(addY > 0)
1516
- // addY = 0;
1526
+ addY = originalRectReadingBody . height / 2 ;
1517
1527
}
1518
1528
1519
1529
translateX = ( scalePrevData . tranX / scalePrevData . scale * scale ) + ( addX / scalePrevData . scale * ( scale - scalePrevData . scale ) ) ;
1520
- translateY = ( scalePrevData . tranY / scalePrevData . scale * scale ) + ( addY / scalePrevData . scale * ( scale - scalePrevData . scale ) ) ;
1521
1530
1522
1531
if ( zoomOut )
1523
1532
translateX = scalePrevData . tranX * ( scale - 1 ) / ( scalePrevData . scale - 1 ) ;
1524
1533
1534
+ let scaleOffsetY = ( originalRect2 . height * _scale - originalRect2 . height ) ;
1535
+
1536
+ translateY = - ( scaleOffsetY * ( scrollTop / scrollHeight ) ) ;
1537
+ translateY = translateY - ( addY * ( scaleOffsetY / originalRect2 . height ) ) ;
1538
+
1539
+ if ( translateY > scrollTop )
1540
+ translateY = scrollTop ;
1541
+ else if ( originalRect2 . height * _scale + translateY < scrollTop + originalRectReadingBody . height )
1542
+ translateY = ( scrollTop + originalRectReadingBody . height ) - originalRect2 . height * _scale ;
1543
+
1525
1544
if ( scale <= 1 )
1526
1545
{
1527
1546
translateX = 0 ;
1528
- if ( scale < 1 ) translateY = 0 ;
1529
1547
haveZoom = false ;
1530
1548
}
1531
1549
else
1532
1550
{
1533
1551
haveZoom = true ;
1534
1552
}
1535
1553
1536
- template . contentRight ( '.reading-body > div' ) . css ( {
1554
+ dom . this ( contentRight ) . find ( '.reading-body > div' ) . css ( {
1537
1555
transition : 'transform ' + animationDurationS + 's, z-index ' + animationDurationS + 's' ,
1538
1556
transform : 'translateX(' + app . roundDPR ( translateX ) + 'px) translateY(' + app . roundDPR ( translateY ) + 'px) scale(' + scale + ')' ,
1539
- transformOrigin : 'center center' ,
1557
+ transformOrigin : 'top center' ,
1540
1558
zIndex : 1 ,
1541
- // willChange: scale == 1 ? '' : 'transform',
1542
1559
} ) ;
1543
1560
1544
1561
applyScaleST = setTimeout ( function ( ) {
1545
1562
1546
- let scrollTop = content . scrollTop ( ) ;
1563
+ let scrollTop = content . scrollTop ;
1547
1564
1548
- let translateY = ( originalRect . height * scale - originalRect . height ) / 2 ;
1565
+ let translateY = 0 ;
1549
1566
1550
- template . contentRight ( '.reading-body' ) . css ( {
1567
+ dom . this ( contentRight ) . find ( '.reading-body' ) . css ( {
1551
1568
height : ( scale == 1 ? '' : ( originalRect . height * scale ) + 'px' ) ,
1552
1569
} ) ;
1553
1570
1554
- template . contentRight ( '.reading-body > div' ) . css ( {
1571
+ dom . this ( contentRight ) . find ( '.reading-body > div' ) . css ( {
1555
1572
transition : 'transform 0s, z-index 0s' ,
1556
1573
transform : 'translateX(' + app . roundDPR ( scalePrevData . tranX ) + 'px) translateY(' + app . roundDPR ( translateY ) + 'px) scale(' + scale + ')' ,
1557
1574
} ) ;
1558
1575
1559
- content . scrollTop ( scrollTop + ( translateY - scalePrevData . tranY ) ) ;
1576
+ content . scrollTop = scrollTop + ( translateY - scalePrevData . tranY ) ;
1560
1577
1561
1578
scalePrevData . tranY = translateY ;
1562
1579
1563
1580
calculateView ( ) ;
1564
1581
disableOnScroll ( false ) ;
1565
1582
zoomingIn = false ;
1566
1583
1584
+ originalRect2 = false ;
1585
+
1567
1586
if ( scale == 1 )
1568
1587
{
1569
1588
originalRect = false ;
1570
1589
currentZoomIndex = false ;
1571
1590
}
1572
1591
1592
+ scalePrevData . _scale = scale ;
1593
+
1573
1594
fixBlurOnZoom ( scale ) ;
1574
1595
1575
1596
} , animationDurationS * 1000 + 100 ) ;
@@ -1578,8 +1599,8 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1578
1599
{
1579
1600
if ( originalRect === false )
1580
1601
{
1581
- originalRect = template . contentRight ( '.image-position' + currentZoomIndex ) . get ( 0 ) . getBoundingClientRect ( ) ;
1582
- originalRectReadingBody = template . contentRight ( ) . children ( ) . get ( 0 ) . getBoundingClientRect ( ) ;
1602
+ originalRect = contentRight . querySelector ( '.image-position' + currentZoomIndex ) . getBoundingClientRect ( ) ;
1603
+ originalRectReadingBody = content . getBoundingClientRect ( ) ;
1583
1604
}
1584
1605
1585
1606
if ( ! zoomOut )
@@ -1616,7 +1637,7 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1616
1637
haveZoom = true ;
1617
1638
}
1618
1639
1619
- template . contentRight ( '.image-position' + currentZoomIndex ) . css ( {
1640
+ dom . this ( contentRight ) . find ( '.image-position' + currentZoomIndex , true ) . css ( {
1620
1641
transition : 'transform ' + animationDurationS + 's, z-index ' + animationDurationS + 's' ,
1621
1642
transform : 'translateX(' + app . roundDPR ( translateX ) + 'px) translateY(' + app . roundDPR ( translateY ) + 'px) scale(' + scale + ')' ,
1622
1643
transformOrigin : 'center center' ,
@@ -1643,6 +1664,7 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
1643
1664
tranY : translateY ,
1644
1665
tranY2 : translateY ,
1645
1666
scale : scale ,
1667
+ _scale : scalePrevData . _scale ,
1646
1668
scrollTop : scrollTop ,
1647
1669
} ;
1648
1670
@@ -1805,23 +1827,25 @@ function dragZoom(x, y)
1805
1827
else if ( y < minY )
1806
1828
y = minY ;
1807
1829
1830
+ let contentRight = template . _contentRight ( ) ;
1831
+
1808
1832
if ( config . readingGlobalZoom && readingViewIs ( 'scroll' ) )
1809
1833
{
1810
1834
scalePrevData . tranX = zoomMoveData . tranX = x ;
1811
1835
zoomMoveData . tranY = scalePrevData . tranY ;
1812
1836
1813
- template . contentRight ( '.reading-body > div' ) . css ( {
1837
+ dom . this ( contentRight ) . find ( '.reading-body > div' ) . css ( {
1814
1838
transition : 'transform 0s, z-index 0s' ,
1815
1839
transform : 'translateX(' + app . roundDPR ( x ) + 'px) translateY(' + app . roundDPR ( scalePrevData . tranY ) + 'px) scale(' + scalePrevData . scale + ')' ,
1816
- transformOrigin : 'center center' ,
1840
+ transformOrigin : 'top center' ,
1817
1841
} ) ;
1818
1842
}
1819
1843
else
1820
1844
{
1821
1845
zoomMoveData . tranX = x ;
1822
1846
zoomMoveData . tranY = y ;
1823
1847
1824
- template . contentRight ( '.image-position' + currentZoomIndex ) . css ( {
1848
+ dom . this ( contentRight ) . find ( '.image-position' + currentZoomIndex , true ) . css ( {
1825
1849
transition : 'transform 0s, z-index 0s' ,
1826
1850
transform : 'translateX(' + app . roundDPR ( x ) + 'px) translateY(' + app . roundDPR ( y ) + 'px) scale(' + scalePrevData . scale + ')' ,
1827
1851
transformOrigin : 'center center' ,
0 commit comments