Skip to content

window.innerWidth/innerHeight are incorrect ways to determine available document sizes #32

@matthew-dean

Description

@matthew-dean

I was using react-sizes to replace some media query stuff, and got some strange behaviors when zooming on iOS. e.g. it would eventually re-render with new sizes even though my device was the same. Like, if I scrolled the page, it would re-render.

The reason: window.innerWidth / innerHeight does not give the document width / height (which is what is useful for components in doing media-query-like stuff in JS), it gives the viewport width. However, pinching / zooming does not fire any sort of event, so basically react-sizes was changing props sort of at random, to values which broke layout.

Instead, this should be using document.documentElement.clientHeight/clientWidth, so that values do not change (eventually) after zooming into the document.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions