AO3-6081 Add optional scroll history tracking#5641
AO3-6081 Add optional scroll history tracking#5641mjec wants to merge 13 commits intootwcode:masterfrom
Conversation
Current features: * Gracefully degrades if features not available (localStorage, onscrollend event) * Prompts for permission to store data * Automatically restores last known scroll position on page load * Stores last 20 scroll positions in localStorage, with functions to move back and forward * `SCROLL_DISTANCE_MINIMUM_FOR_HISTORY` sets minimum pixel length scrolled to record a history entry Things that still need work: * Code is just kind of dropped in application.js * Scroll history is enabled on every page, not just (e.g.) /works * Lacks translations * Prompt is very invasive - is there a better way? * No UI to change preference (browser or user) - might be good to have a global disable user preference? * No UI to delete history * No UI to navigate through history
public/javascripts/application.js
Outdated
|
|
||
| const scroll_history = getScrollHistory(); | ||
| const previous_position = scroll_history.list[scroll_history.index]; | ||
| const new_position = document.scrollingElement?.scrollTop ?? 0; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
Hi, mjec! Thank you so much for this pull request. Someone will be along to review it soon. I've updated the Jira issue status to In Review so no one mistakenly opens a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)." Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you. Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above. |
Pull Request Checklist
AO3-1234 Fix thing)Issue
https://otwarchive.atlassian.net/browse/AO3-6081
Purpose
Adds a scroll history tracking feature, restoring your last scroll position on reload.
Current features:
SCROLL_DISTANCE_MINIMUM_FOR_HISTORYsets minimum pixel length scrolled to record a history entryControlled by a dialog raised by a button next to the Comments button.
Code supports a more comprehensive back/forward, but that might be overkill and I'm not sure the right interface for it anyway (maybe
history.pushState()?)I don't have a lot of (any) experience with cucumber but I'll try to put together a test with that later if you'd like.
I'd of course squash these commits before merge, let me know if/when you want me to squash and force push.
Testing Instructions
Start the service and navigate to a work. Click on the "scroll history is off" button to open a dialog.
Your scroll state will then be automatically restored on a fresh page load, stored independently per page (by URL).
You can view the saved state in the page
localStorage, and only your preference is stored if you opt out.I have tested this on Firefox and Chrome on Windows only right now.
Credit
What name and pronouns should we use to credit you in the Archive of Our Own's Release Notes? mjec (they/them)