Skip to content

Commit

Permalink
Slightly tweaked scroll event bubbling behavior
Browse files Browse the repository at this point in the history
Don't allow wheel events to bubble past this view even if we've scrolled to the edge. It just feels bad to have the scrolling jump unexpectedly from in a container to the outer page. The only exception is when the container fitst the contnet (no scrolling).
  • Loading branch information
Brian Vaughn committed Aug 17, 2021
1 parent 95a1f38 commit 8893622
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ export class VerticalScrollView extends View {
}

_setScrollState(proposedState: ScrollState): boolean {
const height = this._contentView.frame.size.height;
const contentHeight = this._contentView.frame.size.height;
const containerHeight = this.frame.size.height;

const clampedState = clampState({
state: proposedState,
minContentLength: height,
maxContentLength: height,
containerLength: this.frame.size.height,
minContentLength: contentHeight,
maxContentLength: contentHeight,
containerLength: containerHeight,
});
if (!areScrollStatesEqual(clampedState, this._scrollState)) {
this._scrollState.offset = clampedState.offset;
Expand All @@ -275,6 +277,13 @@ export class VerticalScrollView extends View {
return true;
}

return false;
// Don't allow wheel events to bubble past this view even if we've scrolled to the edge.
// It just feels bad to have the scrolling jump unexpectedly from in a container to the outer page.
// The only exception is when the container fitst the contnet (no scrolling).
if (contentHeight === containerHeight) {
return false;
}

return true;
}
}

0 comments on commit 8893622

Please sign in to comment.