} else if (this.props.onScroll) {
this.props.onScroll();
}
+
+ if (!this.lastScrollWasSynthetic) {
+ // If the last scroll wasn't caused by setScrollTop(), assume it was
+ // intentional and cancel any pending scroll reset on mouse idle
+ this.scrollToTopOnMouseIdle = false;
+ }
+ this.lastScrollWasSynthetic = false;
}
}, 150, {
trailing: true,
mouseIdleTimer = null;
mouseMovedRecently = false;
+ lastScrollWasSynthetic = false;
scrollToTopOnMouseIdle = false;
+ setScrollTop = newScrollTop => {
+ if (this.node.scrollTop !== newScrollTop) {
+ this.lastScrollWasSynthetic = true;
+ this.node.scrollTop = newScrollTop;
+ }
+ };
+
clearMouseIdleTimer = () => {
if (this.mouseIdleTimer === null) {
return;
handleMouseIdle = () => {
if (this.scrollToTopOnMouseIdle) {
- this.node.scrollTop = 0;
+ this.setScrollTop(0);
}
this.mouseMovedRecently = false;
this.scrollToTopOnMouseIdle = false;
updateScrollBottom = (snapshot) => {
const newScrollTop = this.node.scrollHeight - snapshot;
- if (this.node.scrollTop !== newScrollTop) {
- this.node.scrollTop = newScrollTop;
- }
+ this.setScrollTop(newScrollTop);
}
getSnapshotBeforeUpdate (prevProps, prevState) {