[OpenLayers-Dev] DragPan issue

Christopher Schmidt crschmidt at metacarta.com
Fri Aug 10 22:05:11 EDT 2007


On Fri, Aug 10, 2007 at 07:03:43PM -0600, Tim Schaub wrote:
> Christopher Schmidt wrote:
> > On Fri, Aug 10, 2007 at 02:43:53PM +0200, Eric Lemoine wrote:
> >> Hi all
> >>
> >> DragPan control does setCenter() even if the mouse pointer hasen't
> >> changed position between mousedown and mouseup. Among other things,
> >> this means a moveend event is triggered on each map click. That
> >> doesn't make much sense to me. What do you think about the attached
> >> patch?
> > 
> > http://trac.openlayers.org/ticket/774
> > 
> > I'm waiting for Ti'ms feedback on this.
> > 
> > -- Chris
> 
> The drag handler can be made smarter (instead of forcing controls that 
> use it to work around its oddities).
> 
> See what you think of the new patch for #774 [1].
> 
> As always, more tests would be great.  I've covered the drag handler 
> adequately - the DragPan control is lacking in tests.

I've added a few tests to DragPan: I think the following will test the
behavior change of the patch:

    function test_Control_DragPan_no_drag (t) {
        t.plan(3);
        
        var data = init_map();
        map = data[0]; control = data[1];
        
        count = 0;
        results = [false, true, false];
        map.setCenter = function(arg1, arg2, arg3) {
             t.eq(results[count], arg3, "dragging arg set correctly");
             count++;
        }
        map.events.triggerEvent('mousedown', {'type':'mousedown',
'xy':new OpenLayers.Pixel(0,0), 'which':1});
        map.events.triggerEvent('mousemove', {'type':'mousemove',
'xy':new OpenLayers.Pixel(0,0), 'which':1});
        map.events.triggerEvent('mouseup', {'type':'mouseup', 'xy':new
OpenLayers.Pixel(0,0), 'which':1});
        map.events.triggerEvent('mousedown', {'type':'mousedown',
'xy':new OpenLayers.Pixel(0,0), 'which':1});
        map.events.triggerEvent('mousemove', {'type':'mousemove',
'xy':new OpenLayers.Pixel(1,1), 'which':1});
        map.events.triggerEvent('mouseup', {'type':'mouseup', 'xy':new
OpenLayers.Pixel(0,0), 'which':1});
    }

Specifically -- the  first mousemove will trigger an extra map.setCenter
call, which shouldn't be there, so the tests will fail.

Does this seem like what you were thinking of? 

In general, I'm in favor of the patch.

Regards, 
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list