Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeniyKiyashko committed Sep 26, 2024
1 parent 351c3a1 commit 3bcb8f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions packages/devextreme/js/__internal/ui/chat/messagelist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { cancelAnimationFrame, requestAnimationFrame } from '@js/animation/frame';
import domAdapter from '@js/core/dom_adapter';
import type { dxElementWrapper } from '@js/core/renderer';
import $ from '@js/core/renderer';
Expand Down Expand Up @@ -37,7 +36,7 @@ class MessageList extends Widget<Properties> {

private _containerClientHeight = 0;

private _shouldSkipContainerResize?: boolean;
private _suppressResizeHandling?: boolean;

private _scrollable!: Scrollable<unknown>;

Expand Down Expand Up @@ -66,7 +65,7 @@ class MessageList extends Widget<Properties> {

this._attachResizeObserverSubscription();

this._shouldSkipContainerResize = true;
this._suppressResizeHandling = true;
}

_attachResizeObserverSubscription(): void {
Expand All @@ -83,16 +82,16 @@ class MessageList extends Widget<Properties> {
}

_resizeHandler({ contentRect, target }: ResizeObserverEntry): void {
if (this._shouldSkipContainerResize
const newHeight = contentRect.height;

if (this._suppressResizeHandling
&& this._isAttached(target)
&& isElementVisible(target as HTMLElement)
) {
this._scrollContentToLastMessage();
this._containerClientHeight = target.clientHeight;

this._shouldSkipContainerResize = false;
this._suppressResizeHandling = false;
} else {
const newHeight = contentRect.height;
const heightChange = this._containerClientHeight - newHeight;

let { scrollTop } = target;
Expand All @@ -102,9 +101,9 @@ class MessageList extends Widget<Properties> {
}

this._scrollable.scrollTo({ top: scrollTop });

this._containerClientHeight = newHeight;
}

this._containerClientHeight = newHeight;
}

_renderEmptyViewContent(): void {
Expand Down Expand Up @@ -168,7 +167,9 @@ class MessageList extends Widget<Properties> {
.appendTo(this.$element());

this._scrollable = this._createComponent($scrollable, Scrollable, {
// useNative: false,
useKeyboard: false,
// showScrollbar: 'always',
bounceEnabled: false,
});
}
Expand Down

0 comments on commit 3bcb8f6

Please sign in to comment.