refactor scroll navigation/restore #750
No reviewers
Labels
No labels
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
channel
comments
community PR
consider soon
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
help wanted
hub-dependent
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
merge when green
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
notifications
odysee
on hold
playlists
priority: blocker
priority: high
priority: low
priority: medium
protocol dependent
recsys
redesign
regression
resilience
sdk dependent
Tom's Wishlist
trending
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-desktop#750
Loading…
Reference in a new issue
No description provided.
Delete branch "scroll-issues"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Doing some refactoring to how the scroll restore works. This fixes the issue where after navigating, pages were scrolled down a bit.
This gets ride of the need to use a
setTimeout
which was required to let the new page load before scrolling. We can handle that inside the app component which I think makes more sense because it is interacting with the DOM. I also added throttling to the scroll listener, no need to constantly fire events when scrolling.After (not sure why my mouse disappeared)
Some things to think about/future ideas
Do we want to restore for all pages? Forwards and back? Not really sure.
If users click the
settings
icon while on the settings page, maybe scroll to the top instead of doing nothing?In addition to the issue highlighted below, this code did not work for me. When navigating to a new page after scrolling, the app still retained a scrolled position rather than scrolling to the top.
This is easy, but it is not simple.
(This is a distinction you will see me make often. Please watch "Simple Made Easy" by Rich Hickey if you have never seen it. It's relatively short and funny and covers one of the most important lessons in programming. You too @liamcardenas)
If all we need is a throttle method, rather than bringing in an entire library, I'd propose simply bringing that method or an analogous one in directly and making it a core part of our code.
From a quick Google, there's no shortage of implementations for throttling javascript events. Here are several in one thread: https://stackoverflow.com/questions/27078285/simple-throttle-in-js
Added the redux to this changelog because I didn't add it to the other PR
One small proposed name change, otherwise looks great. I also tested again and confirmed it is working for me.
This function returns a single entry in the history stack. I would propose a name that better reflects this, perhaps something like
selectCurrentHistoryEntry
(or use "peek" somehow if we want to keep stack terminology consistent).@seanyesmunt you can merge this yourself after addressing above - no need to submit for review again.