commetchat / commet

Your space to connect
https://commet.chat
GNU Affero General Public License v3.0
132 stars 10 forks source link

Jump to specific event in timeline #301

Closed Airyzz closed 6 days ago

Airyzz commented 1 week ago

works by rendering entire timeline offscreen and measuring offset to desired event

Came up with a way more elegant solution: by manipulating the display indices of events in the timeline, we can force an arbitrary event to be positioned at the center of the scroll view. Because of this, we can always assume that the event will begin at scroll position 0.0 and so we can simply scroll to 0 + viewHeight/2 to end up with the event positioned in the center of the view

Super happy with this approach!

Airyzz commented 1 week ago

Related to #243 , but wont close it yet as it currently only works if we want to jump to an even that is already loaded in current timeline. If the event is not yet loaded, this is a separate case which needs to be handled differently