rework mobile view height

This commit is contained in:
David Lechner
2021-02-01 10:26:05 -06:00
parent 3c152a48ea
commit 334668bdfb
7 changed files with 41 additions and 26 deletions
+23
View File
@@ -0,0 +1,23 @@
/* This is a hack for correctly sizing to view height on mobile when not running in fullscreen mode. */
import { ResizeSensor } from '@blueprintjs/core';
import React from 'react';
/* https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ */
function ViewHeightSensor(): JSX.Element {
return (
<ResizeSensor
onResize={(e): void => {
document.documentElement.style.setProperty(
'--pb-vh',
`${e[0].contentRect.height}px`,
);
}}
>
<div id="pb-vh" className="h-100 w-100 p-absolute" />
</ResizeSensor>
);
}
export default ViewHeightSensor;