Commit 0282e94b authored by Michael Henretty's avatar Michael Henretty
Browse files

fix scrolling to top on desktop when changing pages, fixes #311

parent 91b27102
...@@ -296,12 +296,24 @@ export default class Pages extends Component<PagesProps, PagesState> { ...@@ -296,12 +296,24 @@ export default class Pages extends Component<PagesProps, PagesState> {
var self = this; var self = this;
this.content.addEventListener('transitionend', function remove() { this.content.addEventListener('transitionend', function remove() {
self.content.removeEventListener('transitionend', remove); self.content.removeEventListener('transitionend', remove);
self.scroller.scrollTop = 0; // scroll back to the top of the page
self.setState({ // After changing pages we will scroll to the top, which
currentPage: nextProps.currentPage, // is accomplished differentonly on mobile vs. desktop.
pageTransitioning: false, self.scroller.scrollTop = 0; // Scroll up on mobile.
isMenuVisible: false, self.setState(
}); {
currentPage: nextProps.currentPage,
pageTransitioning: false,
isMenuVisible: false,
},
() => {
// Scroll to top on desktop.
window.scrollTo({
top: 0,
behavior: 'smooth',
});
}
);
}); });
this.setState({ this.setState({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment