[OpenLayers-Users] intercepting mouse events that are too rapid in succession

Michael Quentel mquentel at rim.com
Wed Nov 28 21:20:16 EST 2007


Tim,

Thank you very much for the suggestion.

Using the example of wheel event capture at
http://adomas.org/javascript-mouse-wheel/ I made a test script for
capturing mouse wheel "clicks" (ie, each scroll segment or movement of
the wheel) that only records "civilised" mouse wheel movements.  So if
the user goes too fast, the mouse wheel "click" is ignored.  In the
attached example, I set the interval to 0.3 seconds.

Please see attached example.  Please do make suggestions on how this
might be improved.  I plan to implement this functionality into both the
wheel events of MouseDefaults.js, as well as the code that handles the
slider on the zoombar.

Cheers,

Mike Quentel


-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of Tim Schaub
Sent: Wednesday, 28 November 2007 12:15
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] intercepting mouse events that are too
rapid in succession

Hey-

Michael Quentel wrote:
> Via OpenLayers (or other javascript means), any ideas on how to 
> intercept mouse events that are "too rapid" in succession?

You'd have to customize the event handling code to set timers
(window.setTimeout) and only respond to a limited set of events.

> 
> For example, if someone uses a mouse wheel too fast, it would be nice 
> to intercept the movements, then submit the net result to the server, 
> rather than submitting each event that has occurred.  Reason why this 
> is of concern is that some server-side mapping applications are prone 
> to fail if too many requests are made in rapid succession.

Yeah, we'd be better off if mouse wheeling just did a "transition
effect" or "animated zooming" on the client side - not issuing requests
until after scrolling finished (after some delay with no more wheel
events).

The easiest way to modify this behavior right now would be to override
this function:

OpenLayers.Handler.MouseWheel.prototype.onWheelEvent

Basically, you'd want to duplicate the existing code, but execute it
with a window.setTimeout, accruing the wheel delta somewhere (on the
handler) and canceling previous timers when you got a new event.

All this is a bit ugly - and without animated zooming the user will get
no response until they stop scrolling - but it will give your server a
break.

Good luck,
Tim

> I am not using a popular off-the-shelf map server; nor am I using an 
> open source map server.  Please, any advice on intercepting the net 
> result of mouse events is appreciated.
> 
> Many thanks.
> 
> Mike Quentel
> 
> ---------------------------------------------------------------------
> This transmission (including any attachments) may contain confidential
information, privileged material (including material protected by the
solicitor-client or other applicable privileges), or constitute
non-public information. Any use of this information by anyone other than
the intended recipient is prohibited. If you have received this
transmission in error, please immediately reply to the sender and delete
this information from your system. Use, dissemination, distribution, or
reproduction of this transmission by unintended recipients is not
authorized and may be unlawful.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> !DSPAM:4033,474c95ea292781804284693!
> 

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071128/b547dc21/wheeltest4.htm


More information about the Users mailing list