You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/02/01 12:12:45 UTC

[GitHub] [cordova-plugin-statusbar] ronn9419 commented on issue #112: how to get statusbar height

ronn9419 commented on issue #112:
URL: https://github.com/apache/cordova-plugin-statusbar/issues/112#issuecomment-770812109


   This is what I did. 
    - First, set the overlay to false
     - then get the current value of document.documentElement.clientHeight
     - then set the overlay to true
     - then get the current value of document.documentElement.clientHeight
     - the difference of currentHeight  and initialHeight should be the safe area
     
   ```
   const setSafeArea= async () => {
     await Plugins.StatusBar.setOverlaysWebView({
       overlay: false,
     })
     await delay(0)
     const initialHeight = document.documentElement.clientHeight
     await Plugins.StatusBar.setOverlaysWebView({
       overlay: true,
     })
     await delay(0)
     const currentHeight = document.documentElement.clientHeight
     const safeArea = currentHeight - initialHeight
     document.documentElement.style.setProperty('--safe-area-top', `${safeArea}px`)
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org