Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PerryRylance/ec9e407cebb519e668b0a5da504642c5 to your computer and use it in GitHub Desktop.
Save PerryRylance/ec9e407cebb519e668b0a5da504642c5 to your computer and use it in GitHub Desktop.
jQuery(function($) {
if(WPGMZA.isTouchDevice())
{
$(window).on("init.wpgmza", function(event) {
var map = event.target;
// On touch devices, require two fingers to drag and pan
// NB: Temporarily removed due to inconsistent behaviour
map.olMap.getInteractions().forEach(function(interaction) {
if(interaction instanceof ol.interaction.DragPan)
self.olMap.removeInteraction(interaction);
});
map.olMap.addInteraction(new ol.interaction.DragPan({
condition: function(olBrowserEvent) {
var allowed = olBrowserEvent.originalEvent.touches.length == 2;
if(!allowed)
self.showGestureOverlay();
return allowed;
}
}));
map.gestureOverlay.text(WPGMZA.localized_strings.use_two_fingers);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment