[OpenLayers-Dev] OpenLayers dragging issue

Bill Woodall bwoodall at bwoodall.org
Fri Jul 27 13:27:30 EDT 2007


Hi Devlist

A while back VMX had a small patch to Events.js that throttled the
triggerEvent() on mousemoves ( see the updated patch below ).  Not sure
if it ever got a ticket.


........Bill,


Index: lib/OpenLayers/Events.js
===================================================================
--- lib/OpenLayers/Events.js    (revision 3789)
+++ lib/OpenLayers/Events.js    (working copy)
@@ -382,6 +382,20 @@
      */
     fallThrough: null,

+    /**
+     * APIProperty: lastEventMM
+     * {Integer} simple counter to keep down the number of trigger
+     *           events while 'mousemove' is happening
+     */
+    lastEventMM: 0,
+
+    /**
+     * APIProperty: EventMMThreshold
+     * {Integer} threshold for the number of 'mousemove' before
allowing
+     *           an event trigger
+     */
+    EventMMThreshold: 2,
+
     /**
      * Constructor: OpenLayers.Events
      * Construct an OpenLayers.Events object.
@@ -632,8 +646,13 @@
      * evt - {Event}
      */
     handleBrowserEvent: function (evt) {
-        evt.xy = this.getMousePosition(evt);
-        this.triggerEvent(evt.type, evt)
+        if (this.lastEventMM < EventMMThreshold && evt.type ==
"mousemove") {
+            this.lastEventMM++;
+        } else {
+            this.lastEventMM = 0;
+            evt.xy = this.getMousePosition(evt);
+            this.triggerEvent(evt.type, evt);
+        }
     },


On Fri, 2007-07-27 at 08:53 -0500, Les Szklanny wrote:
> Les Szklanny wrote:
> > Hi,
> >
> > I created a simple demo using OL 2.4 and Scriptaculous 1.7.1 beta 3 
> > showing a dragging problem, which I believe is caused by OpenLayers.
> >
> > http://www.slippymap.com/kamap.html
> >
> > Try to quickly drag the 'Powered by Oracle' image.  If you are using 
> > FF or Safari, the image gets disconnected from the cursor, but it 
> > drags quite well on IE 6 and 7.
> >
> > If I comment out the MouseDefaults or MousePosition controls, then 
> > dragging becomes very smooth as one would expect.  The two controls 
> > have handlers that observe mouse movement.
> >
> > Any idea how to fix or work around this problem?
> >
> > Thx,
> > Les Szklanny
> > Where2GetIt
> >
> >
> Hi all and happy Friday :)
> 
> I asked this question a week ago...
> 
> Is there something I can add or clarify?   I'm lost how to handle this 
> problem.
> 
> Thx,
> Les Szklanny
> Where2GetIt
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev




More information about the Dev mailing list