-
Notifications
You must be signed in to change notification settings - Fork 0
Scroll to newly received message if required #420
Conversation
Do not scroll if not previously at the bottom of the list. Change-type: patch Signed-off-by: Graham McCulloch <graham@balena.io>
Firstly, some browsers have trouble scrolling smoothly - the scroll never completes. Secondly, when first loading the timeline, it's more useful to scroll immediately to the bottom. This has actually been requested by users. Change-type: minor Signed-off-by: Graham McCulloch <graham@balena.io>
|
||
// We consider it to be at the bottom if we're within 30 pixels of the bottom | ||
return _.inRange(timelineEndRect.bottom, timelineRect.bottom - 1, timelineRect.bottom + 30) | ||
} catch (error) { |
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.
Why is try-catch needed?
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.
@karaxuna my experience is that React can unset the current
property of refs at inconvenient times. It probably isn't needed but I was nervous about not catching an error. Feel free to convince me it is indeed safe though.
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.
@grahammcculloch I think it will throw if the timelineEnd.current
is detached from dom and you call getBoundingClientRect
. But maybe it can throw in other cases too, so I'm ok with this.
|
||
// We consider it to be at the bottom if we're within 30 pixels of the bottom | ||
return _.inRange(timelineEndRect.bottom, timelineRect.bottom - 1, timelineRect.bottom + 30) | ||
} catch (error) { |
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.
@grahammcculloch I think it will throw if the timelineEnd.current
is detached from dom and you call getBoundingClientRect
. But maybe it can throw in other cases too, so I'm ok with this.
@balena-ci rebase |
8c18bb2
to
892122d
Compare
Scroll to newly received message if required
Do not scroll if not previously at the bottom of the list.
Change-type: patch
Signed-off-by: Graham McCulloch graham@balena.io
Fixes product-os/jellyfish#5948