From e3a799508405f21546a97b43c51c1173582e4e13 Mon Sep 17 00:00:00 2001 From: James Acklin Date: Wed, 3 Feb 2021 00:25:45 -0500 Subject: [PATCH 1/2] chat: calculate from client boxes, not scrollOffset Fixes urbit/landscape#303 --- pkg/interface/src/views/components/OverlaySigil.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/interface/src/views/components/OverlaySigil.tsx b/pkg/interface/src/views/components/OverlaySigil.tsx index b2567596d..312cb9345 100644 --- a/pkg/interface/src/views/components/OverlaySigil.tsx +++ b/pkg/interface/src/views/components/OverlaySigil.tsx @@ -60,14 +60,8 @@ class OverlaySigil extends PureComponent { if (this.containerRef && this.containerRef.current) { const container = this.containerRef.current; const scrollWindow = this.props.scrollWindow; - - const bottomSpace = scrollWindow - ? scrollWindow.scrollHeight - container.offsetTop - scrollWindow.scrollTop - : 'auto'; - const topSpace = scrollWindow - ? scrollWindow.offsetHeight - bottomSpace - OVERLAY_HEIGHT - : 0; - + const bottomSpace = scrollWindow.clientHeight - ((container.getBoundingClientRect().top + OVERLAY_HEIGHT) - scrollWindow.getBoundingClientRect().top); + const topSpace = container.getBoundingClientRect().top - scrollWindow.getBoundingClientRect().top; this.setState({ topSpace, bottomSpace From 94a44462da86551126d63d40e67beed673f35f2e Mon Sep 17 00:00:00 2001 From: James Acklin Date: Wed, 3 Feb 2021 00:29:24 -0500 Subject: [PATCH 2/2] chat: preserve 0 and auto values in space calculations Fixes urbit/landscape#303 --- pkg/interface/src/views/components/OverlaySigil.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/views/components/OverlaySigil.tsx b/pkg/interface/src/views/components/OverlaySigil.tsx index 312cb9345..e94195a87 100644 --- a/pkg/interface/src/views/components/OverlaySigil.tsx +++ b/pkg/interface/src/views/components/OverlaySigil.tsx @@ -60,8 +60,8 @@ class OverlaySigil extends PureComponent { if (this.containerRef && this.containerRef.current) { const container = this.containerRef.current; const scrollWindow = this.props.scrollWindow; - const bottomSpace = scrollWindow.clientHeight - ((container.getBoundingClientRect().top + OVERLAY_HEIGHT) - scrollWindow.getBoundingClientRect().top); - const topSpace = container.getBoundingClientRect().top - scrollWindow.getBoundingClientRect().top; + const bottomSpace = scrollWindow ? scrollWindow.clientHeight - ((container.getBoundingClientRect().top + OVERLAY_HEIGHT) - scrollWindow.getBoundingClientRect().top) : 'auto'; + const topSpace = scrollWindow ? container.getBoundingClientRect().top - scrollWindow.getBoundingClientRect().top : 0; this.setState({ topSpace, bottomSpace @@ -132,4 +132,4 @@ class OverlaySigil extends PureComponent { } } -export default withLocalState(OverlaySigil, ['hideAvatars']); \ No newline at end of file +export default withLocalState(OverlaySigil, ['hideAvatars']);