pmndrs / react-use-measure

🙌 Utility to measure view bounds
MIT License
845 stars 30 forks source link

Zoom style tag can alter the result #101

Open TMarciDev opened 1 month ago

TMarciDev commented 1 month ago

If I use it on a page where the responsive design alters the zoom value on the body to like 75% to make everything fit, the useMeasure will not correct for that and returns smaller values than the actual size.

To correct width and height you can do this:

const [ref, measurement] = useMeasure(input);
const result = { ...measurement, height: getCorrectedSize(measurement.height), width: getCorrectedSize(measurement.width) };

and this will gives back the correct sizes.