@@ -781,24 +781,27 @@ function returnLargerImage(index)
781
781
{
782
782
if ( _config . readingDoublePage && ! _config . readingWebtoon )
783
783
{
784
- var imageHeight0 = template . contentRight ( '.image-position' + ( index ) + '-0' ) . height ( ) ;
785
- var imageHeight1 = template . contentRight ( '.image-position' + ( index ) + '-1' ) . height ( ) ;
784
+ let image0 = template . _contentRight ( ) . querySelector ( '.image-position' + ( index ) + '-0' ) ;
785
+ let image1 = template . _contentRight ( ) . querySelector ( '.image-position' + ( index ) + '-1' ) ;
786
786
787
- if ( imageHeight1 === undefined || imageHeight0 >= imageHeight1 )
788
- {
789
- var image = template . contentRight ( '.image-position' + ( index ) + '-0' ) ;
790
- }
787
+ let rect0 = image0 ? image0 . getBoundingClientRect ( ) : false ;
788
+ let rect1 = image1 ? image1 . getBoundingClientRect ( ) : false ;
789
+
790
+ let imageHeight0 = rect0 . height || 0 ;
791
+ let imageHeight1 = rect1 . height || 0 ;
792
+
793
+ if ( imageHeight0 >= imageHeight1 )
794
+ return { image : image0 , height : imageHeight0 , top : rect0 . top || 0 } ;
791
795
else
792
- {
793
- var image = template . contentRight ( '.image-position' + ( index ) + '-1' ) ;
794
- }
796
+ return { image : image1 , height : imageHeight1 , top : rect1 . top || 0 } ;
795
797
}
796
798
else
797
799
{
798
- var image = template . contentRight ( '.image-position' + ( index ) + '-0' ) ;
799
- }
800
+ let image = template . _contentRight ( ) . querySelector ( '.image-position' + ( index ) + '-0' ) ;
801
+ let rect = image ? image . getBoundingClientRect ( ) : false ;
800
802
801
- return image ;
803
+ return { image : image , height : rect . height || 0 , top : rect . top || 0 } ;
804
+ }
802
805
}
803
806
804
807
var currentPageVisibility = 0 , maxPageVisibility = 0 , currentPageStart = true , readingDirection = true , disableOnScrollST = false ;
@@ -827,13 +830,12 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
827
830
828
831
if ( ( ( nextPrevious && currentPageStart ) || ! nextPrevious || end ) && ( readingViewIs ( 'scroll' ) && ( _config . readingViewAdjustToWidth || _config . readingWebtoon ) ) )
829
832
{
830
- image = returnLargerImage ( eIndex - 1 ) ;
831
-
832
- imgHeight = image . height ( ) + _config . readingMargin . top ;
833
+ let largerImage = returnLargerImage ( eIndex - 1 ) ;
834
+ imgHeight = largerImage . height + _config . readingMargin . top ;
833
835
834
836
if ( imgHeight > contentHeight )
835
837
{
836
- var pageVisibility = Math . floor ( imgHeight / contentHeight )
838
+ let pageVisibility = Math . floor ( imgHeight / contentHeight )
837
839
838
840
maxPageVisibility = pageVisibility ;
839
841
@@ -856,9 +858,8 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
856
858
{
857
859
eIndex = currentIndex ;
858
860
859
- image = returnLargerImage ( eIndex - 1 ) ;
860
-
861
- imgHeight = image . height ( ) + _config . readingMargin . top ;
861
+ let largerImage = returnLargerImage ( eIndex - 1 ) ;
862
+ imgHeight = largerImage . height + _config . readingMargin . top ;
862
863
863
864
if ( readingDirection )
864
865
currentPageVisibility ++ ;
@@ -868,7 +869,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
868
869
if ( nextPrevious !== false && nextPrevious !== true ) currentPageVisibility = nextPrevious ;
869
870
pageVisibilityIndex = currentPageVisibility ;
870
871
871
- var pageVisibility = Math . floor ( imgHeight / contentHeight ) ;
872
+ let pageVisibility = Math . floor ( imgHeight / contentHeight ) ;
872
873
873
874
maxPageVisibility = pageVisibility ;
874
875
@@ -880,9 +881,8 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
880
881
{
881
882
eIndex = index ;
882
883
883
- image = returnLargerImage ( eIndex - 1 ) ;
884
-
885
- imgHeight = image . height ( ) + _config . readingMargin . top ;
884
+ let largerImage = returnLargerImage ( eIndex - 1 ) ;
885
+ imgHeight = largerImage . height + _config . readingMargin . top ;
886
886
887
887
if ( imgHeight > contentHeight )
888
888
{
@@ -917,23 +917,22 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
917
917
}
918
918
else if ( readingViewIs ( 'scroll' ) )
919
919
{
920
- var image = returnLargerImage ( eIndex - 1 ) ;
921
-
922
- var scrollTop = ( image . offset ( ) . top - rect . top ) + content . scrollTop ;
920
+ let largerImage = returnLargerImage ( eIndex - 1 ) ;
921
+ let scrollTop = ( largerImage . top - rect . top ) + content . scrollTop ;
923
922
924
- var scrollSum = 0 ;
923
+ let scrollSum = 0 ;
925
924
926
925
if ( ( readingViewIs ( 'scroll' ) && ( _config . readingViewAdjustToWidth || _config . readingWebtoon ) ) && pageVisibilityIndex !== false )
927
926
{
928
927
imgHeight = image . height ( ) + _config . readingMargin . top ;
929
928
930
929
if ( imgHeight > contentHeight )
931
930
{
932
- var pageVisibility = Math . floor ( imgHeight / contentHeight ) ;
931
+ let pageVisibility = Math . floor ( imgHeight / contentHeight ) ;
933
932
934
933
maxPageVisibility = pageVisibility ;
935
934
936
- var contentHeightRes = ( ( contentHeight * pageVisibility ) - imgHeight ) / pageVisibility ;
935
+ let contentHeightRes = ( ( contentHeight * pageVisibility ) - imgHeight ) / pageVisibility ;
937
936
938
937
scrollSum = ( ( contentHeight - contentHeightRes ) - contentHeight / pageVisibility ) * pageVisibilityIndex ;
939
938
}
@@ -952,7 +951,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
952
951
$ ( content ) . stop ( true ) . animate ( { scrollTop : ( scrollTop + scrollSum ) + 'px' } , animationDurationMS ) ;
953
952
}
954
953
955
- var newIndex = ( eIndex - 1 ) ;
954
+ let newIndex = ( eIndex - 1 ) ;
956
955
957
956
if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
958
957
newIndex = ( indexNum - newIndex ) - 1 ;
0 commit comments