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

Tim Schaub tschaub at openplans.org
Wed Nov 28 12:14:35 EST 2007


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!
> 




More information about the Users mailing list