mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
rework mobile view height
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user