Skip to content

Instantly share code, notes, and snippets.

@snowe2010
Forked from 1forh/index.html
Created January 12, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snowe2010/1bba10277d75913164d3 to your computer and use it in GitHub Desktop.
Save snowe2010/1bba10277d75913164d3 to your computer and use it in GitHub Desktop.
Prevent map zoom on scroll
<div id="map_wrapper">
<iframe id="map_canvas"></iframe>
</div>
// Iframe wrapper ID set to #map_wrapper
// Iframe ID set to #map_canvas
// Prevent map zoom on scroll
// Enable the pointer events only on click
// Disable pointer events on doc ready
$('#map_canvas').addClass('scroll-off');
// Enable pointer events on #map_wrapper click
$('#map_wrapper').on('click', function () {
$('#map_canvas').removeClass('scroll-off');
});
// Disable pointer events when the mouse leaves #map_canvas
$("#map_canvas").mouseleave(function () {
$('#map_canvas').addClass('scroll-off');
});
.scroll-off {
pointer-events: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment