Export ol.Object#dispatchEvent ? #851

Closed
fredj opened this Issue Jul 2, 2013 · 2 comments

2 participants

@fredj
OpenLayers member

What I'm trying to do is a context menu that can be activated on acontextmenu event or (on touch device) after a long press.

The context menu handler:

map.on('contextmenu', function(event) {
  event.preventDefault();
  // something useful here
});

On touch devices, the contextmenu is manually triggered:

var holdTimeout;
map.on('touchstart', function(event) {
  holdTimeout = window.setTimeout(function() {
    // trigger a 'contextmenu' event using the touchstart event
    event.type = 'contextmenu';
    map.trigger(event);
  }, 750);
});
map.on(['touchmove', 'touchend'], function(event) {
  window.clearTimeout(holdTimeout);
});

Is it the right direction?

See https://github.com/fredj/ol3/compare/contextmenu

@twpayne

@fredj, is this still needed?

@fredj
OpenLayers member

no, can be closed

@fredj fredj closed this Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment