MCPcopy
hub / github.com/ollm/OpenComic / stayInLine

Function stayInLine

scripts/reading.js:799–845  ·  view source on GitHub ↗
(resize = false)

Source from the content-addressed store, hash-verified

797}
798
799function stayInLine(resize = false)
800{
801 if(readingViewIs('compact'))
802 {
803 if(currentIndex < 1 && dom.previousComic())
804 showPreviousComic(1, false);
805 else if(currentIndex > contentNum && dom.nextComic())
806 showNextComic(1, false);
807 else
808 pageTransitions.goToIndex(currentIndex, false);
809 }
810 else if(readingViewIs('slide'))
811 {
812 if(currentIndex < 1 && dom.previousComic())
813 showPreviousComic(1, false);
814 else if(currentIndex > contentNum && dom.nextComic())
815 showNextComic(1, false);
816 else
817 goToIndex(currentIndex, false, currentPageVisibility);
818 }
819 else if(readingViewIs('scroll'))
820 {
821 let contentRight = template._contentRight();
822 let content = contentRight.firstElementChild;
823 let rect = content.getBoundingClientRect();
824 let position = imagesFullPosition[currentIndex-1][0];
825
826 disableOnScroll(true);
827
828 if(stayInLineData.scrollTop === false)
829 stayInLineData = {scrollTop: previousScrollTop, scrollHeight: previousScrollHeight, height: previousContentHeight, position: prevImagesFullPosition[currentIndex-1][0], setTimeout: false};
830
831 clearTimeout(stayInLineData.setTimeout);
832 stayInLineData.setTimeout = setTimeout(function(){
833
834 stayInLineData = {scrollTop: false, scrollHeight: false, heigth: false, position: {}, setTimeout: false};
835
836 disableOnScroll(false);
837
838 }, 400);
839
840 let percent = ((stayInLineData.scrollTop + stayInLineData.height / 2) - stayInLineData.position.top) / stayInLineData.position.height;
841
842 let scrollTop = position.top + (percent * position.height) - (rect.height / 2);
843 content.scrollTop = rect.height > stayInLineData.height ? app.ceilDPR(scrollTop) : app.floorDPR(scrollTop);
844 }
845}
846
847let prevChangeHeaderButtons = {};
848

Callers 3

resizedFunction · 0.85
changePagesViewFunction · 0.85
fastUpdateEbookPagesFunction · 0.85

Calls 5

readingViewIsFunction · 0.85
showPreviousComicFunction · 0.85
showNextComicFunction · 0.85
disableOnScrollFunction · 0.85
goToIndexFunction · 0.70

Tested by

no test coverage detected