Skip to content

Commit

Permalink
improve view_ to support smooth scrolling better
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Dec 7, 2022
1 parent 991d1c0 commit db09cef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion content/request_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const showFrameMask = (mask: FrameMaskType): void => {
if (!isTop && mask === FrameMaskType.NormalNext) {
let docEl = docEl_unsafe_();
if (docEl) {
OnChrome && Build.MinCVer < BrowserVer.MinScrollIntoViewOptions
OnChrome && Build.MinCVer < BrowserVer.MinScrollIntoViewOptions && chromeVer_<BrowserVer.MinScrollIntoViewOptions
? ElementProto_not_ff!.scrollIntoViewIfNeeded!.call(docEl) : scrollIntoView_(docEl)
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,13 @@ export const view_ = (el: SafeElement, oldY?: number): VisibilityType => {
let ih = wndSize_(), delta = rect.t < 0 ? -1 : rect.t > ih ? 1 : 0, f = oldY != null,
elHeight = rect.b - rect.t
OnChrome && Build.MinCVer < BrowserVer.MinScrollIntoViewOptions
? scrollIntoView_(el, delta < 0) : scrollIntoView_(el);
? scrollIntoView_(el, delta < 0) : scrollIntoView_(el)
if (f) {
secondScroll = elHeight < ih ? oldY! - scrollY : 0
// required range of wanted: delta > 0 ? [-limit, 0] : [0, limit]
f = delta * secondScroll <= 0 && delta * secondScroll >= elHeight - ih
}
isNotInViewport(el) || // in case of `scroll-behavior: smooth`
(delta || f) && scrollWndBy_(1, f ? secondScroll! * secondScroll! < 4 ? 0 : secondScroll! : delta * ih / 5)
}
return ty
Expand Down

0 comments on commit db09cef

Please sign in to comment.