Skip to content

Commit

Permalink
narratives: Scroll to top after hitting button
Browse files Browse the repository at this point in the history
On mobile narratives, scroll to the top of a page after hitting the
previous or next buttons.
  • Loading branch information
kairstenfay committed Jan 30, 2020
1 parent 5a7fb2b commit 1ef55d1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/narrative/MobileNarrativeDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import Map from "../map/map";
import MainDisplayMarkdown from "./MainDisplayMarkdown";

const BANNER_HEIGHT = 50;

const scrollToTop = () => {
document.getElementById('MobileNarrativeBlock').scrollIntoView();
};

/**
* A React component which takes up the entire screen and displays narratives in
* "mobile" format. Instead of each narrative page displayed as narrative-text in
Expand Down Expand Up @@ -78,6 +83,8 @@ class MobileNarrativeDisplay extends React.Component {
queryToDisplay: {n: idx},
push: true
}));

scrollToTop();
};
// TODO: bind down & up arrows (is this ok since we also have scollable content?)
}
Expand Down

0 comments on commit 1ef55d1

Please sign in to comment.