ALKMaps.Handler.Drag

The drag handler is used to deal with sequences of browser events related to dragging.  The handler is used by controls that want to know when a drag sequence begins, when a drag is happening, and when it has finished.

Controls that use the drag handler typically construct it with callbacks for ‘down’, ‘move’, and ‘done’.  Callbacks for these keys are called when the drag begins, with each move, and when the drag is done.  In addition, controls can have callbacks keyed to ‘up’ and ‘out’ if they care to differentiate between the types of events that correspond with the end of a drag sequence.  If no drag actually occurs (no mouse move) the ‘down’ and ‘up’ callbacks will be called, but not the ‘done’ callback.

Create a new drag handler with the ALKMaps.Handler.Drag constructor.

Inherits from

Summary
ALKMaps.Handler.DragThe drag handler is used to deal with sequences of browser events related to dragging.
Properties
started{Boolean} When a mousedown or touchstart event is received, we want to record it, but not set ‘dragging’ until the mouse moves after starting.
stopDown{Boolean} Stop propagation of mousedown events from getting to listeners on the same element.
dragging{Boolean}
touch{Boolean} When a touchstart event is fired, touch will be true and all mouse related listeners will do nothing.
last{ALKMaps.Pixel} The last pixel location of the drag.
start{ALKMaps.Pixel} The first pixel location of the drag.
lastMoveEvt{Object} The last mousemove event that occurred.
oldOnselectstart{Function}
interval{Integer} In order to increase performance, an interval (in milliseconds) can be set to reduce the number of drag events called.
timeoutId{String} The id of the timeout used for the mousedown interval.
documentDrag{Boolean} If set to true, the handler will also handle mouse moves when the cursor has moved out of the map viewport.
documentEvents{Boolean} Are we currently observing document events?
lockMapPanning{Boolean} Indicates whether or not the handler should prevent the ability to pan the map during a drag event.
panLock{Boolean} Indicates whether or not the handler currently has a lock on panning the map.
Constructor
ALKMaps.Handler.DragReturns ALKMaps.Handler.Drag
Functions
dragstartThis private method is factorized from mousedown and touchstart methods
dragmoveThis private method is factorized from mousemove and touchmove methods
dragendThis private method is factorized from mouseup and touchend methods
downThis method is called during the handling of the mouse down event.
moveThis method is called during the handling of the mouse move event.
upThis method is called during the handling of the mouse up event.
outThis method is called during the handling of the mouse out event.
mousedownHandle mousedown events
touchstartHandle touchstart events
mousemoveHandle mousemove events
touchmoveHandle touchmove events
removeTimeoutPrivate.
mouseupHandle mouseup events
touchendHandle touchend events
mouseoutHandle mouseout events
clickThe drag handler captures the click event.
activateActivate the handler.
deactivateDeactivate the handler.
adjustXYConverts event coordinates that are relative to the document body to ones that are relative to the map viewport.
addDocumentEventsStart observing document events when documentDrag is true and the mouse cursor leaves the map viewport while dragging.
removeDocumentEventsStops observing document events when documentDrag is true and the mouse cursor re-enters the map viewport while dragging.

Properties

started

{Boolean} When a mousedown or touchstart event is received, we want to record it, but not set ‘dragging’ until the mouse moves after starting.

stopDown

{Boolean} Stop propagation of mousedown events from getting to listeners on the same element.  Default is true.

dragging

{Boolean}

touch

{Boolean} When a touchstart event is fired, touch will be true and all mouse related listeners will do nothing.

last

{ALKMaps.Pixel} The last pixel location of the drag.

start

{ALKMaps.Pixel} The first pixel location of the drag.

lastMoveEvt

{Object} The last mousemove event that occurred.  Used to position the map correctly when our “delay drag” timeout expired.

oldOnselectstart

{Function}

interval

{Integer} In order to increase performance, an interval (in milliseconds) can be set to reduce the number of drag events called.  If set, a new drag event will not be set until the interval has passed.  Defaults to 0, meaning no interval.

timeoutId

{String} The id of the timeout used for the mousedown interval.  This is “private”, and should be left alone.

documentDrag

{Boolean} If set to true, the handler will also handle mouse moves when the cursor has moved out of the map viewport.  Default is false.

documentEvents

{Boolean} Are we currently observing document events?

lockMapPanning

{Boolean} Indicates whether or not the handler should prevent the ability to pan the map during a drag event.

panLock

{Boolean} Indicates whether or not the handler currently has a lock on panning the map.

Constructor

ALKMaps.Handler.Drag

Returns ALKMaps.Handler.Drag

Parameters

control{ALKMaps.Control} The control that is making use of this handler.  If a handler is being used without a control, the handlers setMap method must be overridden to deal properly with the map.
callbacks{Object} An object containing a single function to be called when the drag operation is finished.  The callback should expect to receive a single argument, the pixel location of the event.  Callbacks for ‘move’ and ‘done’ are supported.  You can also specify callbacks for ‘down’, ‘up’, and ‘out’ to respond to those events.
options{Object}

Functions

dragstart

dragstart: function (evt)

This private method is factorized from mousedown and touchstart methods

Parameters

evt{Event} The event

Returns

{Boolean} Let the event propagate.

dragmove

dragmove: function (evt)

This private method is factorized from mousemove and touchmove methods

Parameters

evt{Event} The event

Returns

{Boolean} Let the event propagate.

dragend

dragend: function (evt)

This private method is factorized from mouseup and touchend methods

Parameters

evt{Event} The event

Returns

{Boolean} Let the event propagate.

down

down: function(evt)

This method is called during the handling of the mouse down event.  Subclasses can do their own processing here.

Parameters

evt{Event} The mouse down event

move

move: function(evt)

This method is called during the handling of the mouse move event.  Subclasses can do their own processing here.

Parameters

evt{Event} The mouse move event

up

up: function(evt)

This method is called during the handling of the mouse up event.  Subclasses can do their own processing here.

Parameters

evt{Event} The mouse up event

out

out: function(evt)

This method is called during the handling of the mouse out event.  Subclasses can do their own processing here.

Parameters

evt{Event} The mouse out event

mousedown

mousedown: function(evt)

Handle mousedown events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

touchstart

touchstart: function(evt)

Handle touchstart events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

mousemove

mousemove: function(evt)

Handle mousemove events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

touchmove

touchmove: function(evt)

Handle touchmove events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

removeTimeout

removeTimeout: function()

Private.  Called by mousemove() to remove the drag timeout.

mouseup

mouseup: function(evt)

Handle mouseup events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

touchend

touchend: function(evt)

Handle touchend events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

mouseout

mouseout: function (evt)

Handle mouseout events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

click

click: function (evt)

The drag handler captures the click event.  If something else registers for clicks on the same element, its listener will not be called after a drag.

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

activate

activate: function()

Activate the handler.

Returns

{Boolean} The handler was successfully activated.

deactivate

deactivate: function()

Deactivate the handler.

Returns

{Boolean} The handler was successfully deactivated.

adjustXY

adjustXY: function(evt)

Converts event coordinates that are relative to the document body to ones that are relative to the map viewport.  The latter is the default in ALKMaps.

Parameters

evt{Object}

addDocumentEvents

addDocumentEvents: function()

Start observing document events when documentDrag is true and the mouse cursor leaves the map viewport while dragging.

removeDocumentEvents

removeDocumentEvents: function()

Stops observing document events when documentDrag is true and the mouse cursor re-enters the map viewport while dragging.

This class represents a screen coordinate, in x and y coordinates
dragstart: function (evt)
This private method is factorized from mousedown and touchstart methods
dragmove: function (evt)
This private method is factorized from mousemove and touchmove methods
dragend: function (evt)
This private method is factorized from mouseup and touchend methods
down: function(evt)
This method is called during the handling of the mouse down event.
move: function(evt)
This method is called during the handling of the mouse move event.
up: function(evt)
This method is called during the handling of the mouse up event.
out: function(evt)
This method is called during the handling of the mouse out event.
mousedown: function(evt)
Handle mousedown events
touchstart: function(evt)
Handle touchstart events
mousemove: function(evt)
Handle mousemove events
touchmove: function(evt)
Handle touchmove events
removeTimeout: function()
Private.
mouseup: function(evt)
Handle mouseup events
touchend: function(evt)
Handle touchend events
mouseout: function (evt)
Handle mouseout events
click: function (evt)
The drag handler captures the click event.
activate: function()
Activate the handler.
deactivate: function()
Deactivate the handler.
adjustXY: function(evt)
Converts event coordinates that are relative to the document body to ones that are relative to the map viewport.
addDocumentEvents: function()
Start observing document events when documentDrag is true and the mouse cursor leaves the map viewport while dragging.
removeDocumentEvents: function()
Stops observing document events when documentDrag is true and the mouse cursor re-enters the map viewport while dragging.
Returns ALKMaps.Handler.Drag
Base class to construct a higher-level handler for event sequences.
Controls affect the display or behavior of the map.
Close