From 1dfd9ec3f68ea5381bac0b23f101226067ac6ae8 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Mon, 16 Nov 2020 04:07:28 +0200 Subject: [PATCH] Added check for slicer --- src/lib/appManagers/appDialogsManager.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index f5c8a267..a43aae2c 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -739,6 +739,8 @@ export class AppDialogsManager { public onChatsRegularScroll = () => { if(this.sliceTimeout) clearTimeout(this.sliceTimeout); this.sliceTimeout = window.setTimeout(() => { + this.sliceTimeout = undefined; + /* const observer = new IntersectionObserver((entries) => { const }); @@ -747,13 +749,17 @@ export class AppDialogsManager { observer.observe(el); }); */ - const scrollTopWas = this.scroll.scrollTop; + //const scrollTopWas = this.scroll.scrollTop; const rect = this.scroll.container.getBoundingClientRect(); const children = Array.from(this.scroll.splitUp.children) as HTMLElement[]; const firstElement = document.elementFromPoint(rect.x, rect.y) as HTMLElement; const lastElement = document.elementFromPoint(rect.x, rect.y + rect.height - 1) as HTMLElement; + if(!firstElement || !lastElement) { + return; + } + const firstElementRect = firstElement.getBoundingClientRect(); const elementOverflow = firstElementRect.y - rect.y; @@ -804,8 +810,6 @@ export class AppDialogsManager { const scrollTop = */ //this.scroll.scrollIntoView(firstElement, false); - - this.sliceTimeout = undefined; }, 1e3); };