678 B24 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8/**
9 * Get the current UI zoom level, from the --zoom CSS variable.
10 * This is NOT the browser zoom level, that does not need to be accounted for.
11 * This is the UI setting zoom which must be used in width/height computations
12 * instead of e.g. 100vw directly.
13 */
14export function getZoomLevel(): number {
15 try {
16 const number = parseFloat(document.body.style.getPropertyValue('--zoom'));
17 if (isNaN(number)) {
18 return 1;
19 }
20 return number;
21 } catch {}
22 return 1;
23}
24