Created
January 19, 2017 16:51
-
-
Save MAXHEADR0OM/f9dd7edb64632c18047c5f7dfcc3c480 to your computer and use it in GitHub Desktop.
Prevent Google Maps Zoom
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
<div id="map-wrapper"> | |
<iframe id="map-canvas"></iframe> | |
</div> |
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
// Iframe wrapper ID set to #map-wrapper | |
// Iframe ID set to #map-canvas | |
var wrapper = $('#map-wrapper'); | |
var canvas = $('#map-canvas'); | |
// Prevent map zoom on scroll | |
// Enable the pointer events only on click | |
// Disable pointer events on doc ready | |
canvas.addClass('scroll-off'); | |
// Enable pointer events on wrapper click | |
wrapper.on('click', function () { | |
canvas.removeClass('scroll-off'); | |
}); | |
// Disable pointer events when the mouse leaves the canvas | |
canvas.mouseleave(function () { | |
canvas.addClass('scroll-off'); | |
}); |
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
.scroll-off { | |
pointer-events: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment