Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active May 18, 2016 21:44
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 billerickson/ed09c02f05e41d0ae13d5b5ec1923d93 to your computer and use it in GitHub Desktop.
Save billerickson/ed09c02f05e41d0ae13d5b5ec1923d93 to your computer and use it in GitHub Desktop.
jQuery(function($){
// Prevent Google Maps from hijacking scroll
var onMapMouseleaveHandler = function (event) {
var that = $(this);
that.on('click', onMapClickHandler);
that.off('mouseleave', onMapMouseleaveHandler);
that.find('iframe').css("pointer-events", "none");
}
var onMapClickHandler = function (event) {
var that = $(this);
// Disable the click handler until the user leaves the map area
that.off('click', onMapClickHandler);
// Enable scrolling zoom
that.find('iframe').css("pointer-events", "auto");
// Handle the mouse leave event
that.on('mouseleave', onMapMouseleaveHandler);
}
// Enable map zooming with mouse scroll when the user clicks the map
$('.responsive-map').on('click', onMapClickHandler);
});
/* Map
--------------------------------------------- */
.responsive-map {
position: relative;
width: 100%;
height: 0;
padding-bottom: 75%; /* 450/600 */
}
.responsive-map iframe {
position: absolute;
pointer-events: none;
top: 0;
left: 0;
width: 100% !important;
height: 100% !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment