[OpenLayers-Dev] DragPan issue
Tim Schaub
tschaub at openplans.org
Fri Aug 10 21:03:43 EDT 2007
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.
Tim
[1] http://trac.openlayers.org/attachment/ticket/774/dragging.patch
>
>
>> PS: if we agree there's a bug, I'll go ahead and open ticket, with a
>> patch including tests obviously ;-)
>>
>> Thanks,
>>
>> --
>> Eric
>
>> Index: DragPan.js
>> ===================================================================
>> --- DragPan.js (revision 1229)
>> +++ DragPan.js (working copy)
>> @@ -58,11 +58,13 @@
>> panMapDone: function (xy) {
>> var deltaX = this.handler.start.x - xy.x;
>> var deltaY = this.handler.start.y - xy.y;
>> - var size = this.map.getSize();
>> - var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
>> - size.h / 2 + deltaY);
>> - var newCenter = this.map.getLonLatFromViewPortPx( newXY );
>> - this.map.setCenter(newCenter, null, false);
>> + if (deltaX != 0 && deltaY != 0) {
>> + var size = this.map.getSize();
>> + var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
>> + size.h / 2 + deltaY);
>> + var newCenter = this.map.getLonLatFromViewPortPx( newXY );
>> + this.map.setCenter(newCenter, null, false);
>> + }
>> // this assumes xy won't be changed inside Handler.Drag
>> // a safe bet for now, and saves us the extra call to clone().
>> this.handler.start = xy;
>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>
>
More information about the Dev
mailing list