Created
May 17, 2013 13:09
-
-
Save kevingessner/5598913 to your computer and use it in GitHub Desktop.
Detect browser zoom in javascript 'zoom' event is triggered on window on every browser zoom change. No polling!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
</head> | |
<body> | |
<iframe id="frame" style="width: 250px; border: solid 1px red;" ></iframe> | |
<script type="text/javascript"> | |
var elFrame = $('#frame')[0]; | |
$(elFrame.contentWindow).resize(function() { | |
$(window).trigger('zoom'); | |
}); | |
$(window).on('zoom', function() { | |
console.log('zoom', window.devicePixelRatio); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@amit777 For pinch zoom you need the Visual Viewport API.