Refine interaction options #292

twpayne opened this Issue Mar 6, 2013 · 7 comments


None yet

5 participants

twpayne commented Mar 6, 2013

@probins commented:

would be nice to group interactions, so you can do touch:false or keyboard:false

Suggested API:

var map = new ol.Map({
  interactions: ol.interaction.defaults({
    keyboard: false,
    mouseOptions: {
      shiftDragZoom: false
    touch: true,
    touchOptions: {
      pan: true,
      zoom: true,
      rotate: false
  // ...

Of course, with sensible defaults for the platform.

fredj commented Jul 18, 2013

See ol.interaction.defaults function

probins commented Nov 10, 2013

can we revive this one? ISTM it will be quite common for people to want to have interactions specifically for mobile/desktop, and maybe even have a build that only includes the appropriate ones, as with ol2. At the moment, all the interactions are true by default and there is no check whether the symbol is even in the build. Also having to set each interaction to true/false separately is a bit cumbersome. I'm thinking though you could quite easily add, for example, a 'touch' option at the top of the defaults function which would set the individual touch interactions to true/false as appropriate. An alternative would be to have separate mobileDefaults and desktopDefaults or something like that.

twpayne commented Mar 17, 2014

With #1840, I'm not sure if this still makes sense, given that the event handling across mobile and desktop is now unified with pointer events.

@tsauerwein, what is your view?


Partly it still makes sense, because there are interactions that still only work for either touch or mouse. For example a touch option could enable pinchRotate and pinchZoom, while desktop or mouse would enable altShiftDragRotate, mouseWheelZoom and shiftDragZoom.

twpayne commented Mar 17, 2014

So, am I right in thinking that, given that mouse events will never be triggered on pure touch devices, the advantage of this would be simply to reduce the build size in situations where it is known what sort of device is being used?


As far as I can see, yes.

elemoine commented Jul 3, 2014

Closing this for the moment.

@elemoine elemoine closed this Jul 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment