feat: Update scrollToBottom and scrollToTop methods to allow smooth behaviour#259
feat: Update scrollToBottom and scrollToTop methods to allow smooth behaviour#259quietdreamr wants to merge 1 commit into
Conversation
|
Hey @quietdreamr. |
No problem at all. It is not urgent. All the best with the moving process! |
|
Hey, I just had a look at your code and whilst it is great, there are a few things to note:
|
|
Given the work mentioned above and outstanding issues that I still need to get through, I will keep the PR open but not merge it until I am comfortable with preparing it for a new release. (I know that the code does not affect the existing functionality, but because not all of its branches can be activated - I do not want to confuse any other devs that may be using/analysing this project's code). Thankyou for your great initiative once again! |
JiwaniZakir
left a comment
There was a problem hiding this comment.
The changes in elementUtils.ts look solid overall — replacing direct scrollTop assignment with scrollTo() is the right approach for enabling smooth scroll behavior. A few observations:
The ternary (smooth ? 'smooth' : 'instant') can be simplified to just passing smooth ? 'smooth' : 'instant' without the extra parentheses, which is a minor style nit. More importantly, behavior: 'instant' has limited browser support compared to the old element.scrollTop = value pattern — it behaves as auto in some browsers, so it's worth verifying the fallback behavior is acceptable across target environments (particularly older Safari versions).
Also worth considering: callers of scrollToBottom that are invoked during streaming or auto-scroll may call this frequently in rapid succession. With smooth: true, overlapping smooth scroll calls can interfere with each other and cause jittery behavior, so any callers enabling smooth scroll should be reviewed to ensure they debounce or only trigger on discrete user-facing actions rather than continuous updates. It may be worth adding a note about this in the method's JSDoc or in the PR description to guide future callers.
Uses the scrollTo() method instead of directly setting the scrollTop. By default, it will still scroll instantly. When passing
smooth = true, it'll set the behaviour tosmooth.