Last active
July 25, 2018 14:48
-
-
Save MAXHEADR0OM/2edecd2713241d9953bc2d4d60ccd8a4 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