-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct links to narrative sections #418
Conversation
Pull Request Test Coverage Report for Build 811011867
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome...I noticed a behavior that I'm not sure is intended:
- Navigate to a section by entering it into the url (i.e. prison/3)
- Select a different Data Narrative (i.e. probation)
- See that it navigates to probation/3 - I would have expected it to go to probation/1
scrollToSection, | ||
sectionsContainerRef, | ||
getOnSectionExpanded, | ||
onInViewChange, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what you think about calling this variable onSectionInViewChange
, might be easier to read later on without needing to checkout the note in the hook.
@daschi hmmm good catch, that is indeed not intended. i'll look into it! |
turns out the same layout component was re-rendering when the narrative changed so the "initial" section of the first load was persisting as you navigated. (this wasn't happening until I consolidated everything into a hook instead of passing some of it as props, which was the last thing I did before opening this PR, so my earlier testing didn't catch it.) I added a more targeted reaction to clear it when you go to a new page, using a local Mobx observable |
Description of the change
Revives and revamps the direct section linking feature (disabled here to unblock the v2 launch).
(The new behavior is different enough from the old that it's probably not a useful reference, but I include it nonetheless for context).
In some ways I think this is less complicated than it was the first time around because it relies on native browser behavior rather than JS for smooth scrolling and snapping. But it's not not complicated ... the new complexity here involves keeping track of where the user is on the page to prevent the linked section from being pushed down the viewport by content loading above it.
The end result should be that you can link directly to any section and it will scroll cleanly into your viewport when the page loads, and the page URL will stay in sync as you move up and down the page and can be grabbed at any time from the location bar to reflect your current view.
To summarize the highlights of how we got there:
Type of change
Related issues
Checklists
Development
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: