Use CSS var in JS
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
f5d8bb7cbe
commit
499b470d07
2 changed files with 11 additions and 3 deletions
|
@ -18,6 +18,10 @@ $button-size: 32px;
|
||||||
$icon-size: 22px;
|
$icon-size: 22px;
|
||||||
$button-gap: 24px;
|
$button-gap: 24px;
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--image-view-panel-height: 68px;
|
||||||
|
}
|
||||||
|
|
||||||
.mx_ImageView {
|
.mx_ImageView {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -40,7 +44,7 @@ $button-gap: 24px;
|
||||||
|
|
||||||
.mx_ImageView_panel {
|
.mx_ImageView_panel {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 68px;
|
height: var(--image-view-panel-height);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -46,7 +46,11 @@ const ZOOM_COEFFICIENT = 0.0025;
|
||||||
const ZOOM_DISTANCE = 10;
|
const ZOOM_DISTANCE = 10;
|
||||||
|
|
||||||
// Height of mx_ImageView_panel
|
// Height of mx_ImageView_panel
|
||||||
const PANEL_HEIGHT = 68;
|
const getPanelHeight = (): number => {
|
||||||
|
const value = getComputedStyle(document.documentElement).getPropertyValue("--image-view-panel-height");
|
||||||
|
// Return the value as a number without the unit
|
||||||
|
return parseInt(value.slice(0, value.length - 2));
|
||||||
|
};
|
||||||
|
|
||||||
interface IProps extends IDialogProps {
|
interface IProps extends IDialogProps {
|
||||||
src: string; // the source of the image being displayed
|
src: string; // the source of the image being displayed
|
||||||
|
@ -103,7 +107,7 @@ export default class ImageView extends React.Component<IProps, IState> {
|
||||||
thumbnailInfo?.positionY +
|
thumbnailInfo?.positionY +
|
||||||
(thumbnailInfo?.height / 2) -
|
(thumbnailInfo?.height / 2) -
|
||||||
(UIStore.instance.windowHeight / 2) -
|
(UIStore.instance.windowHeight / 2) -
|
||||||
(PANEL_HEIGHT / 2)
|
(getPanelHeight() / 2)
|
||||||
) ?? 0,
|
) ?? 0,
|
||||||
moving: false,
|
moving: false,
|
||||||
contextMenuDisplayed: false,
|
contextMenuDisplayed: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue