-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Scrolling functionality on short webtoons #3006
base: develop
Are you sure you want to change the base?
Changes from all commits
be3fc1c
c6070a3
e4ed24a
69db7e6
bf75239
a9e1e56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,11 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy, | |
this.cdRef.markForCheck(); | ||
} | ||
|
||
// Used to catch webtoons smaller than the viewport height. | ||
heightLessThanView() { | ||
return this.getTotalHeight() < this.getViewportHeight(); | ||
} | ||
|
||
getVerticalOffset() { | ||
const reader = this.isFullscreenMode ? this.readerElemRef.nativeElement : this.document.body; | ||
|
||
|
@@ -300,6 +305,19 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy, | |
|| 0); | ||
} | ||
|
||
onWheel(event: WheelEvent) { | ||
if (!this.heightLessThanView()) { | ||
// Only execute on small webtoons. | ||
return; | ||
} | ||
|
||
if (event.deltaY > 0) { | ||
this.loadNextChapter.emit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't update the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think it is a good idea so you know the direction you were last scrolling. It wont matter much, but better to have. |
||
} else if (event.deltaY < 0) { | ||
this.loadPrevChapter.emit(); | ||
} | ||
} | ||
|
||
/** | ||
* On scroll in document, calculate if the user/javascript has scrolled to the current image element (and it's visible), update that scrolling has ended completely, | ||
* and calculate the direction the scrolling is occuring. This is not used for prefetching. | ||
|
@@ -354,6 +372,10 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy, | |
return Math.round(totalHeight); | ||
} | ||
|
||
getViewportHeight() { | ||
return window.innerHeight; | ||
} | ||
|
||
getTotalScroll() { | ||
if (this.isFullscreenMode) { | ||
return this.readerElemRef.nativeElement.offsetHeight + this.readerElemRef.nativeElement.scrollTop; | ||
|
@@ -563,7 +585,7 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy, | |
} | ||
|
||
handleBottomIntersection(entries: IntersectionObserverEntry[]) { | ||
if (entries.length > 0 && this.pageNum > this.totalPages - 5 && this.initFinished) { | ||
if (!this.heightLessThanView() && entries.length > 0 && this.pageNum > this.totalPages - 5 && this.initFinished) { | ||
this.debugLog('[Intersection] The whole bottom spacer is visible', entries[0].isIntersecting); | ||
this.loadNextChapter.emit(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help me understand the arbitrary 300px? Is this just from the styles? If so, let's make it a css variable and use var(--) on the property so I don't forget to update it in multiple places.