Forked from https://github.com/yonran/detect-zoom
As of January 2013 @yonran stopped maintaining his source, and is pointing to this repository
Major changes from the original code:
- I removed support for old browsers and cleaned up the original code.
Supported browsres: IE8+, FF4+, modern Webkit, mobile Webkit, Opera 11.1+ - Added AMD and CommonJS support ("require" and "exports")
Detect-zoom has only two external functions:
zoom()
Returns the zoom level of the user's browser using Javascript.device()
Returns the device pixel ratio multiplied by the zoom level (Read more about devicePixelRatio at QuirksMode)
This can be used to show higher-resolution canvas
or img
when necessary.
I'm maitaining it to use Detect-zoom in Wix.com's editor to warn users that their browser is in zoom mode before saving imporant changes to their wabsite.
It is not complete, I need help testing different browsers, patches welcome.
http://tombigel.github.com/detect-zoom/
<script src="detect-zoom.js"></script>
<script>
var zoom = detectZoom.zoom();
var device = detectZoom.device();
console.log(zoom, device);
</script>
require(['detect-zoom'], function(detectZoom){
var zoom = detectZoom.zoom();
});
Detect-zoom is dual-licensed under the WTFPL and MIT license, at the recipient's choice.