Disable Chrome pinch zoom for use in kiosk

前端 未结 6 2177

We are using Chrome in kiosk mode and accidentally users are causing the application to zoom with the recent addition of pinch zoom support. They then think they\'ve broken it

6条回答
  •  广开言路
    2021-01-30 11:16

    I'm dealing with the same issue. I think I can handle it reasonably well with the following approach

    • determine the css pixel width of the html element: document.documentElement.clientWidth
    • compare this measurement to the known pixel width of the kiosk screen
    • if the html element is wider, in css pixels than the screen is, in physical pixels, that means it's scaled
    • if the html element is scaled, apply a zoom to the body element to compensate. The formula is `body.style.zoom = htmlElementClientWidth / screenPhysicalPixelWidth

    This techique has the beneficial side effect of automatically scaling the UI to whatever size the current window is, which is helpful for development if I'm developing on a screen smaller than the target screen.

    More on screen pixels vs css pixels, and a discussion of how the html element expands to fill the available space at quirksmode.org.

提交回复
热议问题