settimeout based scrolltobottom replaced with nexttick#295
Conversation
…llback to a separate, named function
…setTimeout with nextTick; moved scrollToBottom to its own function
…xtTick based behavior
abelsiqueira
left a comment
There was a problem hiding this comment.
Thanks for the PR, great work.
I noticed that the screen moves down as well as the inner box (when it's zoomed in), so I made a suggestion I found in [1].
I noticed the scrollToBottom function is the same for all screens, can it be factored out for reuse?
[1] https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move/11041376
| scrollToBottom() | ||
| } | ||
| const scrollToBottom = () => { | ||
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) |
There was a problem hiding this comment.
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) | |
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' }) |
| editingId.value = -1 | ||
| } | ||
| const scrollToBottom = () => { | ||
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) |
There was a problem hiding this comment.
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) | |
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' }) |
|
|
||
| function addKeyword () { | ||
| const scrollToBottom = () => { | ||
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) |
There was a problem hiding this comment.
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' }) | |
| document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth', block: 'nearest' }) |
|
Thanks for the review, and for the useful link. I've refactored scrollToBottom to be a separate function that is now imported in 3 places. I went with |
abelsiqueira
left a comment
There was a problem hiding this comment.
The block: 'end' option moves it up if your app is scrolled down. Should affect different devices as well as people who zoom in a lot. I don't know how it works, but block: 'nearest' seems to fix it.
Reproduce: On a fresh app, zoom to ~125%, scroll down, add a new author.
|
OK, made changes as requested |
abelsiqueira
left a comment
There was a problem hiding this comment.
Thanks for the fixes, it's working great now. 🍋
|
Yay, good job being persistent. Glad we were able to get it working |
Pull request details
List of related issues or pull requests
Refs: #288
Describe the changes made in this pull request
This PR replaces the
setTimeoutbased scroll-to-bottom behavior withnextTickbased behavior. Also in this PR:ScreenKeywords,ScreenAuthors, andScreenIdentifiersby moving the function defintions to separate functionsInstructions to review the pull request
go to localhost:8080, see if the app works correctly. Particularly, add authors, keywords or identifiers to the point where the list is longer than what fits the page. then scroll up, then click add author/keyword/identifier. The list should scroll down smoothly to the new, emtpy item at the bottom of the list.