@@ -855,21 +855,38 @@ function changeHeaderButtons(scrollInStart = null, scrollInEnd = null)
855855
856856 if ( ( scrollInStart === null || scrollInStart ) && currentIndex == 1 && ! ( ( readingViewIs ( 'scroll' ) && ( _config . readingViewAdjustToWidth || _config . readingWebtoon ) ) && currentPageVisibility > 0 ) )
857857 {
858- prevIsPrevComic = true ;
859- canGoPrev = dom . previousComic ( ) ;
858+ if ( readingManga ( ) )
859+ {
860+ prevIsPrevComic = true ;
861+ canGoPrev = dom . nextComic ( ) ;
862+ }
863+ else
864+ {
865+ prevIsPrevComic = true ;
866+ canGoPrev = dom . previousComic ( ) ;
867+ }
860868 }
861869
862870 if ( ( scrollInEnd === null || scrollInEnd ) && currentIndex == indexNum && ! ( ( readingViewIs ( 'scroll' ) && ( _config . readingViewAdjustToWidth || _config . readingWebtoon ) ) && currentPageVisibility < maxPageVisibility ) )
863871 {
864- nextIsNextComic = true ;
865- canGoNext = dom . nextComic ( ) ;
872+ if ( readingManga ( ) )
873+ {
874+ nextIsNextComic = true ;
875+ canGoNext = dom . previousComic ( ) ;
876+ }
877+ else
878+ {
879+ nextIsNextComic = true ;
880+ canGoNext = dom . nextComic ( ) ;
881+ }
866882 }
867883
868884 let currentChangeHeaderButtons = {
869885 prevIsPrevComic : prevIsPrevComic ,
870886 nextIsNextComic : nextIsNextComic ,
871887 canGoPrev : canGoPrev ,
872888 canGoNext : canGoNext ,
889+ readingManga : readingManga ( ) ,
873890 } ;
874891
875892 if ( ! isEqual ( prevChangeHeaderButtons , currentChangeHeaderButtons ) )
@@ -880,12 +897,14 @@ function changeHeaderButtons(scrollInStart = null, scrollInEnd = null)
880897 dom . this ( [ next , lastPage ] ) . class ( ! canGoNext , 'disable-pointer' ) ;
881898
882899 firstPage . innerHTML = prevIsPrevComic ? 'skip_previous' : 'first_page' ;
883- firstPage . setAttribute ( 'hover-text' , prevIsPrevComic ? language . reading . prevChapter : language . reading . firstPage ) ;
884-
885900 lastPage . innerHTML = nextIsNextComic ? 'skip_next' : 'last_page' ;
886- lastPage . setAttribute ( 'hover-text' , nextIsNextComic ? language . reading . nextChapter : language . reading . lastPage ) ;
887901
888- if ( config . readingTrackingAtTheEnd && ! trackingCurrent && ( ( _config . readingManga && prevIsPrevComic ) || ( ! _config . readingManga && nextIsNextComic ) ) )
902+ prev . setAttribute ( 'hover-text' , readingManga ( ) ? language . reading . next : language . reading . previous ) ;
903+ next . setAttribute ( 'hover-text' , readingManga ( ) ? language . reading . previous : language . reading . next ) ;
904+ firstPage . setAttribute ( 'hover-text' , readingManga ( ) ? ( prevIsPrevComic ? language . reading . nextChapter : language . reading . lastPage ) : ( prevIsPrevComic ? language . reading . prevChapter : language . reading . firstPage ) ) ;
905+ lastPage . setAttribute ( 'hover-text' , readingManga ( ) ? ( nextIsNextComic ? language . reading . prevChapter : language . reading . firstPage ) : ( nextIsNextComic ? language . reading . nextChapter : language . reading . lastPage ) ) ;
906+
907+ if ( config . readingTrackingAtTheEnd && ! trackingCurrent && ( ( readingManga ( ) && prevIsPrevComic ) || ( ! readingManga ( ) && nextIsNextComic ) ) )
889908 {
890909 trackingCurrent = true ;
891910 tracking . track ( ) ;
@@ -1014,7 +1033,7 @@ function goToImage(imageIndex, disableSave = false)
10141033
10151034 let newIndex = imagesData [ imageIndex ] . position + 1 ;
10161035
1017- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
1036+ if ( readingManga ( ) )
10181037 newIndex = ( indexNum - newIndex ) + 1 ;
10191038
10201039 calculateRealReadingDirection ( newIndex ) ;
@@ -1033,7 +1052,7 @@ function goToFolder(folderIndex)
10331052
10341053 let newIndex = foldersPosition [ folderIndex ] + 1 ;
10351054
1036- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
1055+ if ( readingManga ( ) )
10371056 newIndex = ( indexNum - newIndex ) + 1 ;
10381057
10391058 calculateRealReadingDirection ( newIndex ) ;
@@ -1340,7 +1359,7 @@ function goToIndex(index, animation = true, nextPrevious = false, end = false)
13401359
13411360 let newIndex = ( eIndex - 1 ) ;
13421361
1343- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
1362+ if ( readingManga ( ) )
13441363 newIndex = ( indexNum - newIndex ) - 1 ;
13451364
13461365 if ( updateCurrentIndex )
@@ -1416,7 +1435,7 @@ function goToChapterProgress(chapterIndex, chapterProgress, animation = true)
14161435 if ( readingDoublePage ( ) )
14171436 index = Math . ceil ( index / 2 ) ;
14181437
1419- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
1438+ if ( readingManga ( ) )
14201439 index = ( indexNum - closest . page . index ) ;
14211440
14221441 reading . goToIndex ( index , animation ) ;
@@ -1445,11 +1464,11 @@ function goNext()
14451464
14461465 music . soundEffect . page ( ) ;
14471466 }
1448- else if ( currentIndex == indexNum && dom . nextComic ( ) && ( ! _config . readingManga || readingViewIs ( 'scroll' ) ) )
1467+ else if ( currentIndex == indexNum && dom . nextComic ( ) && ! readingManga ( ) )
14491468 {
14501469 showNextComic ( 1 , true ) ;
14511470 }
1452- else if ( currentIndex == indexNum && dom . previousComic ( ) && _config . readingManga && ! readingViewIs ( 'scroll' ) )
1471+ else if ( currentIndex == indexNum && dom . previousComic ( ) && readingManga ( ) )
14531472 {
14541473 showNextComic ( 1 , true , true ) ;
14551474 }
@@ -1477,11 +1496,11 @@ function goPrevious()
14771496
14781497 music . soundEffect . page ( ) ;
14791498 }
1480- else if ( previousIndex == 0 && dom . previousComic ( ) && ( ! _config . readingManga || readingViewIs ( 'scroll' ) ) )
1499+ else if ( previousIndex == 0 && dom . previousComic ( ) && ! readingManga ( ) )
14811500 {
14821501 showPreviousComic ( 1 , true ) ;
14831502 }
1484- else if ( previousIndex == 0 && dom . nextComic ( ) && _config . readingManga && ! readingViewIs ( 'scroll' ) )
1503+ else if ( previousIndex == 0 && dom . nextComic ( ) && readingManga ( ) )
14851504 {
14861505 showPreviousComic ( 1 , true , true ) ;
14871506 }
@@ -1490,11 +1509,12 @@ function goPrevious()
14901509//Go to the start of the comic
14911510function goStart ( force = false )
14921511{
1493- if ( force || ! _config . readingManga || readingViewIs ( 'scroll' ) )
1512+ if ( force || ! readingManga ( ) || 1 )
14941513 {
1514+ const hasComic = readingManga ( ) ? dom . nextComic ( ) : dom . previousComic ( ) ;
14951515 saveReadingProgressA = true ;
14961516
1497- if ( ( currentIndex > indexNum || ( currentIndex - 1 == 0 && dom . previousComic ( ) ) ) && ( ! maxPageVisibility || currentPageVisibility == 0 ) )
1517+ if ( ( currentIndex > indexNum || ( currentIndex - 1 == 0 && hasComic ) ) && ( ! maxPageVisibility || currentPageVisibility == 0 ) )
14981518 {
14991519 goPrevious ( ) ;
15001520
@@ -1518,7 +1538,9 @@ function goStart(force = false)
15181538
15191539function goPrevComic ( )
15201540{
1521- if ( dom . previousComic ( ) )
1541+ const hasComic = readingManga ( ) ? dom . nextComic ( ) : dom . previousComic ( ) ;
1542+
1543+ if ( hasComic )
15221544 {
15231545 let speed = _config . readingViewSpeed ;
15241546 _config . readingViewSpeed = 0 ;
@@ -1533,11 +1555,12 @@ function goPrevComic()
15331555//Go to the end of the comic
15341556function goEnd ( force = false )
15351557{
1536- if ( force || ! _config . readingManga || readingViewIs ( 'scroll' ) )
1558+ if ( force || ! readingManga ( ) || 1 )
15371559 {
1560+ const hasComic = readingManga ( ) ? dom . previousComic ( ) : dom . nextComic ( ) ;
15381561 saveReadingProgressA = true ;
15391562
1540- if ( ( currentIndex < 1 || ( currentIndex == indexNum && dom . nextComic ( ) ) ) && ( ! maxPageVisibility || maxPageVisibility == currentPageVisibility ) )
1563+ if ( ( currentIndex < 1 || ( currentIndex == indexNum && hasComic ) ) && ( ! maxPageVisibility || maxPageVisibility == currentPageVisibility ) )
15411564 {
15421565 goNext ( ) ;
15431566
@@ -1561,7 +1584,9 @@ function goEnd(force = false)
15611584
15621585function goNextComic ( )
15631586{
1564- if ( dom . nextComic ( ) )
1587+ const hasComic = readingManga ( ) ? dom . previousComic ( ) : dom . nextComic ( ) ;
1588+
1589+ if ( hasComic )
15651590 {
15661591 let speed = _config . readingViewSpeed ;
15671592 _config . readingViewSpeed = 0 ;
@@ -3034,6 +3059,11 @@ function readingDoublePage()
30343059 return ( _config . readingDoublePage && ! _config . readingWebtoon ) ;
30353060}
30363061
3062+ function readingManga ( )
3063+ {
3064+ return ( _config . readingManga && ! readingViewIs ( 'scroll' ) ) ;
3065+ }
3066+
30373067var activeOnScroll = true ;
30383068
30393069function disableOnScroll ( disable = true )
@@ -3380,7 +3410,7 @@ function reloadIndex()
33803410 let imageIndex = false ;
33813411 let newIndex = ( currentIndex - 1 ) ;
33823412
3383- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
3413+ if ( readingManga ( ) )
33843414 newIndex = ( indexNum - newIndex ) - 1 ;
33853415
33863416 eachImagesDistribution ( newIndex , [ 'image' ] , function ( image ) {
@@ -3496,7 +3526,7 @@ function createAndDeleteBookmark(index = false)
34963526
34973527 let newIndex = ( currentIndex - 1 ) ;
34983528
3499- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
3529+ if ( readingManga ( ) )
35003530 newIndex = ( indexNum - newIndex ) - 1 ;
35013531
35023532 eachImagesDistribution ( newIndex , [ 'image' ] , function ( image ) {
@@ -3601,7 +3631,7 @@ function saveReadingProgress(path = false, mainPath = false)
36013631
36023632 let newIndex = ( currentIndex - 1 ) ;
36033633
3604- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
3634+ if ( readingManga ( ) )
36053635 newIndex = ( indexNum - newIndex ) - 1 ;
36063636
36073637 eachImagesDistribution ( newIndex , [ 'image' ] , function ( image ) {
@@ -4588,7 +4618,7 @@ async function generateEbookPages(end = false, reset = false, fast = false, imag
45884618
45894619 let newIndex = currentIndex ;
45904620
4591- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
4621+ if ( readingManga ( ) )
45924622 newIndex = ( indexNum - newIndex ) + 1 ;
45934623
45944624 if ( nextOpenChapterProgress )
@@ -4611,7 +4641,7 @@ function currentImagePosition()
46114641{
46124642 let index = currentIndex - 1 ;
46134643
4614- if ( _config . readingManga && ! reading . readingViewIs ( 'scroll' ) )
4644+ if ( readingManga ( ) )
46154645 index = ( indexNum - index ) - 1 ;
46164646
46174647 return index ;
@@ -5620,7 +5650,7 @@ async function read(path, index = 1, end = false, isCanvas = false, isEbook = fa
56205650
56215651 var newIndex = currentIndex ;
56225652
5623- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
5653+ if ( readingManga ( ) )
56245654 newIndex = ( indexNum - newIndex ) + 1 ;
56255655
56265656 goToIndex ( newIndex , false , end , end ) ;
@@ -5675,7 +5705,7 @@ async function read(path, index = 1, end = false, isCanvas = false, isEbook = fa
56755705
56765706 var newIndex = currentIndex ;
56775707
5678- if ( _config . readingManga && ! readingViewIs ( 'scroll' ) )
5708+ if ( readingManga ( ) )
56795709 newIndex = ( indexNum - newIndex ) + 1 ;
56805710
56815711 goToIndex ( newIndex , false , end , end ) ;
@@ -5810,6 +5840,8 @@ module.exports = {
58105840 rotateImage : rotateImage ,
58115841 setIsLoaded : function ( value ) { isLoaded = value } ,
58125842 isLoaded : function ( value ) { return isLoaded } ,
5843+ doublePage : readingDoublePage ,
5844+ manga : readingManga ,
58135845 isLoad : isLoad ,
58145846 onLoad : onLoad ,
58155847 ebook : readingEbook ,
0 commit comments