-
-
Save bateller/88e9e4f1dd2330ccc170 to your computer and use it in GitHub Desktop.
Prevent map zoom on scroll
This file contains hidden or 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 hidden or 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 | |
// 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'); | |
}); |
This file contains hidden or 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