Commit Graph

65 Commits

Author SHA1 Message Date
Tim Schaub
d5d005ba3f Allow interactions to deal directly with browser events
The relayEvent_ method wraps goog's browser events in our MapBrowserEvent.  This allows interactions to deal with real browser events in addition to our emulated events.
2013-11-01 13:07:44 -06:00
Éric Lemoine
d81fe5ac95 Map browser event handler refactoring
This commit refactors the code of the map browser event handler. The changes are the following:

Previously the `handleTouch*_` listener functions handled both `touch*` and `mspointer*` events. With this commit we use per-event type listeners. This duplicates some code (could be avoidable), but makes it easier to introduce mouse/touch/pointer specific treatments in the future.

We now listen to pointermove, pointerup, touchmove and touchend only when needed. In this way we're assured that a `down` event was received (and that `this.down_` is set) when the `up` or `move` listeners are called. This fixes the bug @oterral reported on the mailing list: https://groups.google.com/d/msg/ol3-dev/jR844F7Nlg8/eN9dt4uATK0J.

To avoid problems in browsers that trigger different types of events (e.g. both mouse and pointer events) the `down` listeners unregister the other `down` listeners. For example, the `pointerdown` listener unregisters the `mousedown` and `touchstart` listeners, for ever.
2013-10-31 13:35:01 +01:00
Éric Lemoine
8402eee0c3 Map "click" event renamed to "singleclick"
As discussed with @tschaub in #1195.
2013-10-31 09:37:16 +01:00
Éric Lemoine
0fa66cc7e7 Remove mousedown listener on first touchstart 2013-10-30 13:16:09 +01:00
Éric Lemoine
9f7ead5ef4 Remove unused ol.MapBrowserEventHandler#relayEvent_ func 2013-10-30 13:16:09 +01:00
Éric Lemoine
a85b82090d Emulate click events only on mouse "action"
`click` events are fired only if the mouse action button is pressed. This prevents `click` events from being fired when the middle mouse button is used.

Also, without this commit, in Chrome with emulated touch events enabled, double-clicking the map doesn't zoom the map. This is because `ol.BrowserFeature.HAS_TOUCH` is `false` in that environment. The commit fixes it by testing `isMouseActionButton` on mouse devices only.
2013-10-30 13:16:09 +01:00
Éric Lemoine
0c212fdcb5 Emulated click events on mouse devices
The map already emits emulated `click` and `dblclick` events on touch and pointer devices. With this commit the map emits emulated `click` and `dblclick` events on mouse devices as well.
2013-10-30 13:16:09 +01:00
Paul Spencer
bada596b45 Add default stability level to docs of exported things. 2013-10-24 18:20:24 -04:00
Éric Lemoine
08bad9746b Do not relay mouseout events 2013-10-18 10:00:53 +02:00
Éric Lemoine
70eb5a5f13 Emulate click and dblclick on touch devices 2013-10-18 09:59:47 +02:00
Éric Lemoine
938f45a032 Do not relay mousemove events 2013-10-18 09:59:46 +02:00
Éric Lemoine
1c051aa055 Do not relay contextmenu events 2013-10-18 09:59:46 +02:00
Éric Lemoine
4c04c9fa5c Use getCoordinatePixel in ol.MapBrowserEvent 2013-10-14 15:36:46 +02:00
Éric Lemoine
49e0af5abb Use getEventPixel in ol.MapBrowserEvent 2013-10-14 15:36:37 +02:00
Frederic Junod
f994c4f8a1 Only dispatch touchmove events after a touchstart 2013-09-03 09:35:30 +02:00
Frederic Junod
2b5e0c2c31 Change touchmove and touchstart listened element to 'document'
As for the mouse events, this allows to drag, zoom or rotate the map
with pointer(s) who moved outside of the viewport.
2013-09-03 09:35:30 +02:00
Frederic Junod
ecf953a125 Remove pressed_ variable and rely on down_ to check if a mouse button is pressed 2013-08-28 11:28:50 +02:00
Frederic Junod
dc5b209f7f Change previous_ local variable type to boolean
And rename it to pressed_ for clarity; the variable represents whether
the mouse button is pressed
2013-08-28 11:16:45 +02:00
Frederic Junod
9306704c1d Add documentation in mapbrowserevent.js 2013-08-28 11:16:44 +02:00
Frederic Junod
d43581719b IE pointer events names are now defined in goog.events.EventType 2013-07-23 08:50:57 +02:00
Éric Lemoine
6fc4aa68b6 Remove ol.MapBrowserEvent#stopOtherInteractions
and check for false/true in the return from handleMapBrowserEvent. Refs #791.
2013-06-27 14:43:00 +02:00
ahocevar
a405279f34 Click handler called with empty event object on Android
On Android (both native browser and Chrome), the handleTouchEnd_
method is sometimes reached in a state where this.down_ is null.
This check protects against this.click_ being called without
an event object. To see this issue, open any example in Android,
and tap the zoom + or - button.
2013-06-24 10:35:02 +02:00
Frederic Junod
fd5f4f3dd8 API doc strings for preventDefault and stopPropagation
thanks @elemoine
2013-06-18 15:02:42 +02:00
Frederic Junod
bed44dd82c Add ol.MapBrowserEvent.stopOtherInteractions
When called, stops the interaction chain.
2013-06-18 13:02:17 +02:00
Frederic Junod
2bd87313cd ol.MapBrowserEvent: call browserEvent.{preventDefault|stopPropagation} 2013-06-18 11:31:44 +02:00
Frederic Junod
1de3ffe57e Relay contextmenu browser event 2013-06-12 14:14:25 +02:00
Frederic Junod
d05bb872f3 Relay mouseout browser event 2013-06-07 09:48:15 +02:00
Frederic Junod
ece2a4b64c Store listener keys into an array instead of individual variables 2013-06-06 12:08:32 +02:00
Frederic Junod
be081fd44e Redefine ol.Pixel to be Array.<number> 2013-05-31 15:53:04 +02:00
Tom Payne
11672db967 Use === and !== for comparisons with 0 2013-05-28 16:07:48 +02:00
ahocevar
00777de581 Do not check for listeners, as suggested by @fredj 2013-04-30 14:45:47 +02:00
ahocevar
cc1b70c74b Giving the map a getFeatureInfoForPixel method
This method is an entry point for getting feature information.
Renderers can use a hit canvas or defer to a layer (source) to
get matching features for a pixel.

For now this is only implemented for vector layers, and it uses
a bbox query because we cannot refine the result because of
missing geometry intersection functions yet.
2013-04-30 13:32:16 +02:00
ahocevar
a437bea61f Use no browser globals at all 2013-04-10 16:53:45 +02:00
Tom Payne
4be8c991f7 Add missing Closure Library requires 2013-04-06 14:28:12 +02:00
szymonc
569fb81572 Add goog.base(this) to the MapBrowserEventHandler's constructor 2013-04-05 00:01:16 +02:00
Frederic Junod
0a80feccfc Allow touch event (touchstart) to fire click events 2013-03-03 14:45:12 +01:00
Frederic Junod
8c1d42a318 Listen to both mouse and touch events 2013-02-20 09:33:04 +01:00
Frederic Junod
ccd568ca3b Remove unused goog.require 2013-02-20 09:31:40 +01:00
Frederic Junod
a066b323f2 Move dblclick handling into touch handlers 2013-02-20 09:31:40 +01:00
Frederic Junod
942255e177 Listen to IE pointer events 2013-02-20 09:31:40 +01:00
Frederic Junod
0d42e08785 Add listeners for touchstart, touchmove and touchend events 2013-02-20 09:31:40 +01:00
Frederic Junod
dc40ac6831 Remove touch events handling in handleMouse* handlers 2013-02-20 09:31:39 +01:00
Frederic Junod
0296380807 Rename MapBrowserEventHandler internal handlers name 2013-02-20 09:31:39 +01:00
Tom Payne
93976a5d9f Fix requires relating to recent commits 2013-01-30 23:47:13 +01:00
Bruno Binet
39cbba3eb7 Add a frameState property to ol.MapBrowserEvent
so that we will be able to retrieve the current center of the view2d from the
framestate in the dragpan interaction.
2013-01-29 13:00:02 +01:00
Frederic Junod
f8646394ae Remove event listener with goog.events.unlistenByKey 2013-01-28 10:37:32 +01:00
Frederic Junod
9e030854b2 Don't remove event listener for this.handleUp_ twice.
The listener key is in this.dragListenerKeys_
2013-01-28 10:31:24 +01:00
Frederic Junod
01098c4d8c Remove event listener with goog.events.unlistenByKey 2013-01-28 10:26:09 +01:00
Frederic Junod
f208e99c64 Add missing goog.events.EventType.DBLCLICK argument to unlisten 2013-01-28 09:54:41 +01:00
Tom Payne
386bb636bb Add missing dependencies on goog.array 2013-01-21 14:20:11 +01:00