The click and hover handlers need to take care that the event they are handling doesn't get modified before the delayed listeners get called. Appears to only be a problem in IE. Thanks for the catch madair. r=crschmidt (closes #1393)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6414 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -159,7 +159,10 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
this.clearTimer();
|
this.clearTimer();
|
||||||
} else {
|
} else {
|
||||||
// set the timer, send evt only if single is true
|
// set the timer, send evt only if single is true
|
||||||
var clickEvent = this.single ? evt : null;
|
//use a clone of the event object because it will no longer
|
||||||
|
//be a valid event object in IE in the timer callback
|
||||||
|
var clickEvent = this.single ?
|
||||||
|
OpenLayers.Util.extend({}, evt) : null;
|
||||||
this.timerId = window.setTimeout(
|
this.timerId = window.setTimeout(
|
||||||
OpenLayers.Function.bind(this.delayedCall, this, clickEvent),
|
OpenLayers.Function.bind(this.delayedCall, this, clickEvent),
|
||||||
this.delay
|
this.delay
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
this.clearTimer();
|
this.clearTimer();
|
||||||
this.callback('move', [evt]);
|
this.callback('move', [evt]);
|
||||||
this.px = evt.xy;
|
this.px = evt.xy;
|
||||||
|
// clone the evt so original properties can be accessed even
|
||||||
|
// if the browser deletes them during the delay
|
||||||
|
evt = OpenLayers.Util.extend({}, evt);
|
||||||
this.timerId = window.setTimeout(
|
this.timerId = window.setTimeout(
|
||||||
OpenLayers.Function.bind(this.delayedCall, this, evt),
|
OpenLayers.Function.bind(this.delayedCall, this, evt),
|
||||||
this.delay
|
this.delay
|
||||||
|
|||||||
@@ -129,10 +129,10 @@
|
|||||||
t.fail("clearTimeout called with non-existent timerId");
|
t.fail("clearTimeout called with non-existent timerId");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var testEvt = Math.random();
|
var testEvt = {id: Math.random()};
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"click": function(evt) {
|
"click": function(evt) {
|
||||||
t.eq(evt, testEvt,
|
t.eq(evt.id, testEvt.id,
|
||||||
"(click w/ single true) click callback called with correct evt");
|
"(click w/ single true) click callback called with correct evt");
|
||||||
},
|
},
|
||||||
"dblclick": function(evt) {
|
"dblclick": function(evt) {
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
// mouse moves one pixel, click should be called
|
// mouse moves one pixel, click should be called
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"click": function(evt) {
|
"click": function(evt) {
|
||||||
t.ok(evt == clickEvt, "(pixelTolerance met) click called");
|
t.ok(evt.xy == clickEvt.xy, "(pixelTolerance met) click called");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
map.events.triggerEvent("click", clickEvt);
|
map.events.triggerEvent("click", clickEvt);
|
||||||
|
|||||||
@@ -78,16 +78,16 @@
|
|||||||
var testEvt;
|
var testEvt;
|
||||||
|
|
||||||
// test pause and move callbacks - four tests here (2 from setTimeout above)
|
// test pause and move callbacks - four tests here (2 from setTimeout above)
|
||||||
testEvt = Math.random();
|
testEvt = {id: Math.random()};
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"pause": function(evt) {
|
"pause": function(evt) {
|
||||||
t.eq(evt, testEvt,
|
t.eq(evt.id, testEvt.id,
|
||||||
"pause callback called with correct evt");
|
"pause callback called with correct evt");
|
||||||
},
|
},
|
||||||
"move": function(evt) {
|
"move": function(evt) {
|
||||||
t.eq(evt, testEvt,
|
t.eq(evt.id, testEvt.id,
|
||||||
"move callback called with correct evt");
|
"move callback called with correct evt");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
map.events.triggerEvent("mousemove", testEvt);
|
map.events.triggerEvent("mousemove", testEvt);
|
||||||
handler.clearTimer();
|
handler.clearTimer();
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
// mouse moves 3x3 pixels, callbacks should be called
|
// mouse moves 3x3 pixels, callbacks should be called
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"pause": function(evt) {
|
"pause": function(evt) {
|
||||||
t.ok(evt == testEvt, "(pixelTolerance unmet) pause callback called");
|
t.ok(evt.xy == testEvt.xy, "(pixelTolerance unmet) pause callback called");
|
||||||
},
|
},
|
||||||
"move": function(evt) {
|
"move": function(evt) {
|
||||||
t.ok(evt == testEvt, "(pixelTolerance unmet) move callback called");
|
t.ok(evt == testEvt, "(pixelTolerance unmet) move callback called");
|
||||||
|
|||||||
Reference in New Issue
Block a user