From 9cb36b9568aedc11a4ba4bc2d86dc3e3bc869988 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Sat, 27 Feb 2021 18:10:04 +0400 Subject: [PATCH] Scroll to start of conversation --- src/components/chat/bubbles.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index c2f3ec4f..218979c6 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -1204,6 +1204,17 @@ export default class ChatBubbles { forceDuration?: number ) { // * 4 = .25rem + const bubble = findUpClassName(element, 'bubble'); + + // * if it's a start, then scroll to start of the group + if(position === 'center' && whichChild(bubble) === (this.stickyIntersector ? 2 : 1)) { + const dateGroup = bubble.parentElement; + if(whichChild(dateGroup) === 0) { + element = dateGroup; + position = 'start'; + } + } + return this.scrollable.scrollIntoViewNew(element, position, 4, undefined, forceDirection, forceDuration); }