Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clicking on thumb track scrolls up or down about one page of content
  • Loading branch information
Brian Vaughn committed Aug 10, 2021
commit 0c21bac36e6de9a08247a78ca35edb47582e6dee
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,23 @@ class VerticalScrollBarView extends View {
_handleClick(interaction: ClickInteraction, viewRefs: ViewRefs) {
const {location} = interaction.payload;
if (rectContainsPoint(location, this.frame)) {
const currentScrollThumbY = this._scrollThumbRect.origin.y;
const y = location.y;

if (rectContainsPoint(location, this._scrollThumbRect)) {
// Ignore clicks on the track thumb directly.
return;
}

const currentScrollThumbY = this._scrollThumbRect.origin.y;
const y = location.y;

const {height} = this.frame.size;

// Scroll up or down about one viewport worth of content:
// TODO This calculation is broken
const deltaY = this.frame.size.height * 0.8;
const deltaY = (height / this._contentHeight) * height * 0.8;

this.setScrollThumbY(
y < currentScrollThumbY
? currentScrollThumbY - deltaY
: currentScrollThumbY + deltaY,
y > currentScrollThumbY
? this._scrollThumbRect.origin.y + deltaY
: this._scrollThumbRect.origin.y - deltaY,
);
}
}
Expand Down