Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Export ol.Object#dispatchEvent ? #851

Closed
fredj opened this Issue · 2 comments

2 participants

Frédéric Junod Tom Payne
Frédéric Junod
Owner

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

Tom Payne

@fredj, is this still needed?

Frédéric Junod
Owner

no, can be closed

Frédéric Junod fredj closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.