Merge pull request #224 from jorix/3402-touch_logic_to_superclass
Move some touch logic to the `handler` base class
This commit is contained in:
@@ -85,6 +85,14 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
* the OpenLayers code.
|
||||
*/
|
||||
evt: null,
|
||||
|
||||
/**
|
||||
* Property: touch
|
||||
* {Boolean} Indicates the support of touch events. When touch events are
|
||||
* started touch will be true and all mouse related listeners will do
|
||||
* nothing.
|
||||
*/
|
||||
touch: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Handler
|
||||
@@ -187,10 +195,32 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
this.unregister(events[i], this[events[i]]);
|
||||
}
|
||||
}
|
||||
this.touch = false;
|
||||
this.active = false;
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: startTouch
|
||||
* Start touch events, this method must be called by subclasses in
|
||||
* "touchstart" method. When touch events are started <touch> will be
|
||||
* true and all mouse related listeners will do nothing.
|
||||
*/
|
||||
startTouch: function() {
|
||||
if (!this.touch) {
|
||||
this.touch = true;
|
||||
var events = [
|
||||
"mousedown", "mouseup", "mousemove", "click", "dblclick",
|
||||
"mouseout"
|
||||
];
|
||||
for (var i=0, len=events.length; i<len; i++) {
|
||||
if (this[events[i]]) {
|
||||
this.unregister(events[i], this[events[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: callback
|
||||
* Trigger the control's named callback with the given arguments
|
||||
|
||||
Reference in New Issue
Block a user