Ticket #1255 (closed feature: fixed)

Opened 5 years ago

Last modified 5 years ago

Hover handler inclusion

Reported by: elemoine Owned by: elemoine
Priority: major Milestone: 2.6 Release
Component: Handler.Hover Version: SVN
Keywords: Cc:
State: Complete

Description

People want a mechanism where an action is triggered as the mouse goes over the map and pause - to send requests to some search service for example. See this: <http://openlayers.org/pipermail/users/2007-December/004254.html>.

The attached patch introduces the hover handler for that.

Patch includes the hover handler, an example and tests.

Credits: this hover handler was Tim's idea.

Attachments

patch-1255-r5682-A0.diff Download (18.0 KB) - added by elemoine 5 years ago.
Tim's comments taken into account
patch-1255-r5682-A1.diff Download (18.0 KB) - added by elemoine 5 years ago.
change passesTolerance() ND comment
patch-1255-r5715-B0.diff Download (18.7 KB) - added by elemoine 5 years ago.
new patch with two callbacks: "pause" and "move"
patch-1255-r5738-B1.diff Download (19.5 KB) - added by elemoine 5 years ago.
update to B0 patch, stopPropag renamed stopMove, add initialize() method

Change History

  Changed 5 years ago by elemoine

Ignore patch-1252-r5674-A0.diff, which was a patch for #1252

follow-up: ↓ 3   Changed 5 years ago by tschaub

  • state set to Commit

Nice work Eric. This is really cool. Two minor tweaks (for IE) in the example: removing trailing commas from lines 60 and 102 (hover-handler.html).

This will be great to have in the library. Please commit with the above changes.

(The other issue I was just reminded of is the poor destroy coverage we have on controls/handlers. We really need to go through the controls and make sure they destroy their handlers on destroy - and that those handlers deactivate themselves on destroy to remove event listeners. I added a ticket for this previously.)

in reply to: ↑ 2 ; follow-up: ↓ 4   Changed 5 years ago by elemoine

Replying to tschaub:

Nice work Eric. This is really cool. Two minor tweaks (for IE) in the example: removing trailing commas from lines 60 and 102 (hover-handler.html).

Thanks for catching this. I'll append an updated patch.

This will be great to have in the library. Please commit with the above changes.

Will do tomorrow, after I give it some extra testing on other browsers.

(The other issue I was just reminded of is the poor destroy coverage we have on controls/handlers. We really need to go through the controls and make sure they destroy their handlers on destroy - and that those handlers deactivate themselves on destroy to remove event listeners. I added a ticket for this previously.)

If the handlers call their parent's destroy method they should be ok. See < http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Handler.js#L251>.

Changed 5 years ago by elemoine

Tim's comments taken into account

Changed 5 years ago by elemoine

change passesTolerance() ND comment

in reply to: ↑ 3   Changed 5 years ago by tschaub

Replying to elemoine:

Replying to tschaub:

(The other issue I was just reminded of is the poor destroy coverage we have on controls/handlers. We really need to go through the controls and make sure they destroy their handlers on destroy - and that those handlers deactivate themselves on destroy to remove event listeners. I added a ticket for this previously.)

If the handlers call their parent's destroy method they should be ok. See < http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Handler.js#L251>.

Yeah, it's more a problem the other way (controls not destroying their handlers). For example, go to  http://openlayers.org, open firebug, and enter

c = map.controls[0];
map.destroy();

Then enjoy exploring things like

c.dragPan.handler.map.layerContainerDiv // etc.

Changed 5 years ago by elemoine

new patch with two callbacks: "pause" and "move"

  Changed 5 years ago by elemoine

I attached a new patch. With this patch, a new callback is available: "move". This callback is called on mousemoves when the mouse actually moves (i.e. does not pause). This callback is necessary for the user to be able to abort an Ajax request sent when the mouse paused. This callback can be used for other things like closing a popup. I also renamed the "hover" callback, it's now named "pause".

Tim, does the patch still look ok?

Tests pass on FF.

follow-up: ↓ 7   Changed 5 years ago by crschmidt

Eric:

Quick comment -- can we call 'stopPropag' 'stopMove' instead? In the future, we may want to have seperate events for the different things that we're stopping propogation on possibly? I really don't like 'stopPropoag', in either case -- if we think we'll always want to stop as a group, then stopPropogation seems more right to me.

in reply to: ↑ 6   Changed 5 years ago by elemoine

Replying to crschmidt:

Eric: Quick comment -- can we call 'stopPropag' 'stopMove' instead? In the future, we may want to have seperate events for the different things that we're stopping propogation on possibly? I really don't like 'stopPropoag', in either case -- if we think we'll always want to stop as a group, then stopPropogation seems more right to me.

Thanks for the review Chris. I agree to rename 'stopPropag' 'stopMove'. Will update the patch...

Changed 5 years ago by elemoine

update to B0 patch, stopPropag renamed stopMove, add initialize() method

  Changed 5 years ago by elemoine

I tested the hover-handler.html example on FF2/Linux, IE6, IE7, Opera9/Windows, Safari3/Windows. It works in all. Unit tests pass on FF2, IE6 and IE7; not run on Opera9 and Safari3.

  Changed 5 years ago by crschmidt

Still looks fine -- please continue to feel free to commit :)

  Changed 5 years ago by elemoine

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [5746]) Add hover handler. With this handler user-defined actions can be triggered as the mouse moves over the map and pauses. An example of use is send WMS/GetFeatureInfo requests. r=crschmidt,tschaub (closes #1255)

  Changed 5 years ago by tschaub

  • component changed from Handler to Handler.Hover
Note: See TracTickets for help on using tickets.