fix: show toast when browser zoom is not 100%

This commit is contained in:
Aakansha Doshi 2022-06-14 13:52:00 +05:30
parent f1bc90e08a
commit d12b592232
2 changed files with 15 additions and 1 deletions

View file

@ -887,6 +887,19 @@ class App extends React.Component<AppProps, AppState> {
} }
private onResize = withBatchedUpdates(() => { private onResize = withBatchedUpdates(() => {
if (!this.deviceType.isMobile) {
const scrollBarWidth = 10;
const widthRatio =
(window.outerWidth - scrollBarWidth) / window.innerWidth;
const isBrowserZoomed =
// Device pixel ratio is 2 when zoom is 100%
window.devicePixelRatio !== 2 || widthRatio < 0.9 || widthRatio > 1;
if (isBrowserZoomed) {
this.setToastMessage(t("alerts.browserZoom"));
} else {
this.clearToast();
}
}
this.scene this.scene
.getElementsIncludingDeleted() .getElementsIncludingDeleted()
.forEach((element) => invalidateShapeForElement(element)); .forEach((element) => invalidateShapeForElement(element));

View file

@ -181,7 +181,8 @@
"invalidSceneUrl": "Couldn't import scene from the supplied URL. It's either malformed, or doesn't contain valid Excalidraw JSON data.", "invalidSceneUrl": "Couldn't import scene from the supplied URL. It's either malformed, or doesn't contain valid Excalidraw JSON data.",
"resetLibrary": "This will clear your library. Are you sure?", "resetLibrary": "This will clear your library. Are you sure?",
"removeItemsFromsLibrary": "Delete {{count}} item(s) from library?", "removeItemsFromsLibrary": "Delete {{count}} item(s) from library?",
"invalidEncryptionKey": "Encryption key must be of 22 characters. Live collaboration is disabled." "invalidEncryptionKey": "Encryption key must be of 22 characters. Live collaboration is disabled.",
"browserZoom": "Your browser's zoom level is not set to 100% which may cause the board to display incorrectly"
}, },
"errors": { "errors": {
"unsupportedFileType": "Unsupported file type.", "unsupportedFileType": "Unsupported file type.",