chat: preserve 0 and auto values in space calculations

Fixes urbit/landscape#303
This commit is contained in:
James Acklin 2021-02-03 00:29:24 -05:00
parent e3a7995084
commit 94a44462da

View File

@ -60,8 +60,8 @@ class OverlaySigil extends PureComponent<OverlaySigilProps, OverlaySigilState> {
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<OverlaySigilProps, OverlaySigilState> {
}
}
export default withLocalState(OverlaySigil, ['hideAvatars']);
export default withLocalState(OverlaySigil, ['hideAvatars']);