@ -553,6 +553,12 @@ class App extends React.Component<AppProps, AppState> {
< Toast
message = { this . state . toastMessage }
clearToast = { this . clearToast }
duration = {
this . state . toastMessage === t ( "alerts.browserZoom" )
? Infinity
: undefined
}
closable = { this . state . toastMessage === t ( "alerts.browserZoom" ) }
/ >
) }
< main > { this . renderCanvas ( ) } < / main >
@ -766,6 +772,7 @@ class App extends React.Component<AppProps, AppState> {
? { . . . scene . appState . activeTool , type : "selection" }
: scene . appState . activeTool ,
isLoading : false ,
toastMessage : this.state.toastMessage || null ,
} ;
if ( initialData ? . scrollToContent ) {
scene . appState = {
@ -904,6 +911,7 @@ class App extends React.Component<AppProps, AppState> {
} else {
this . updateDOMRect ( this . initializeScene ) ;
}
this . checkIfBrowserZoomed ( ) ;
}
public componentWillUnmount() {
@ -916,8 +924,21 @@ class App extends React.Component<AppProps, AppState> {
clearTimeout ( touchTimeout ) ;
touchTimeout = 0 ;
}
private checkIfBrowserZoomed = ( ) = > {
if ( ! this . device . isMobile ) {
const scrollBarWidth = 10 ;
const widthRatio =
( window . outerWidth - scrollBarWidth ) / window . innerWidth ;
const isBrowserZoomed = widthRatio < 0.75 || widthRatio > 1.1 ;
if ( isBrowserZoomed ) {
this . setToastMessage ( t ( "alerts.browserZoom" ) ) ;
} else {
this . clearToast ( ) ;
}
}
} ;
private onResize = withBatchedUpdates ( ( ) = > {
this . checkIfBrowserZoomed ( ) ;
this . scene
. getElementsIncludingDeleted ( )
. forEach ( ( element ) = > invalidateShapeForElement ( element ) ) ;