AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.9.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

namespace anychart.graphics.events Improve this Doc

A namespace of all global functions of the ACGraph event model.

Functions Overview

listen()Adds an event listener for an event to a DOM node or to an implementing object.
listenOnce()Adds an event listener for a certain event to a DOM node or to an implementing object.
removeAll()Removes all listeners from an object.
unlisten()Removes a listener added using listen() or listenOnce() methods.
unlistenByKey()Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Enums Overview

anychart.graphics.events.EventTypeConstants for event names.

Classes Overview

anychart.graphics.events.BrowserEventEncapsulates browser event for anychart.graphics.

Functions Description

listen

Adds an event listener for an event to a DOM node or to an implementing object.

Params:

NameTypeDefaultDescription
targetanychart.graphics.vector.Element
The object to attach the event listener to.
typestring | Array.<string>
The type of event or the array of types.
listenerfunction | Object | null
The event listener or the object with the handleEvent function.
captboolean
false
Calls event handling in the capture phase.
handlerObject
The element in scope of which the listener is called.

Returns:

Object - The unique key for the event listener.

listenOnce

Adds an event listener for a certain event to a DOM node or to an implementing object.

Params:

NameTypeDefaultDescription
targetanychart.graphics.vector.Element
The object to attach the event listener to.
typestring | Array.<string>
The type of event or the array of types.
listenerfunction | Object | null
The event listener.
captboolean
false
Calls event handling in the capture phase.
handlerObject
The element in scope of which the listener is called.

Returns:

Object - The unique key for the event listener.

removeAll

Removes all listeners from an object.

Params:

NameTypeDescription
targetanychart.graphics.vector.ElementThe object to remove listeners from.
typestringType of event to be removed, default is all types.

Returns:

number - Number of listeners removed.

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

NameTypeDescription
targetanychart.graphics.vector.ElementThe object on which to stop listening to the event.
typestring | Array.<string>The type of event or the array of types of events you want to stop listening to.
listenerfunction | Object | nullThe listener to be removed.
captbooleanIn DOM-compatible browsers this parameter defines if the listener is called in the capture or in the bubble phase of the event.
handlerObjectThe element in scope of which the listener is called.

Returns:

boolean - Shows if the removed listener existed.

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

NameTypeDescription
keyObjectThe key returned by listen() for this event listener.

Returns:

boolean - Indicating whether the listener was there to remove.