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.EventType | Constants for event names. |
Classes Overview
anychart.graphics.events.BrowserEvent | Encapsulates browser event for anychart.graphics. |
Functions Description
listen
Adds an event listener for an event to a DOM node or to an implementing object.
Detailed description
The listener can be added to an object once, and if it is added one more time,
its key will be returned.
Note: Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.
Note: Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.
Params:
Name | Type | Default | Description |
---|---|---|---|
target | anychart.graphics.vector.Element | The object to attach the event listener to. | |
type | string | Array.<string> | The type of event or the array of types. | |
listener | function | Object | null | The event listener or the object with the handleEvent function. | |
capture | boolean | false | Calls event handling in the capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
handler | Object | The element in scope of which the listener is called. |
Returns:
Object - The unique key for the event listener.Try it:
listenOnce
Adds an event listener for a certain event to a DOM node or to an implementing object.
Detailed description
After the event is called, its handler will be deleted.
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).
Params:
Name | Type | Default | Description |
---|---|---|---|
target | anychart.graphics.vector.Element | The object to attach the event listener to. | |
type | string | Array.<string> | The type of event or the array of types. | |
listener | function | Object | null | The event listener. | |
capture | boolean | false | Calls event handling in the capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
handler | Object | The element in scope of which the listener is called. |
Returns:
Object - The unique key for the event listener.Try it:
removeAll
Removes all listeners from an object.
Detailed description
You can also optionally remove listeners of some particular type.
Params:
Name | Type | Description |
---|---|---|
target | anychart.graphics.vector.Element | The object to remove listeners from. |
type | string | Type of event to be removed, default is all types. |
Returns:
number - Number of listeners removed.Try it:
unlisten
Removes a listener added using listen() or listenOnce() methods.
Params:
Name | Type | Description |
---|---|---|
target | anychart.graphics.vector.Element | The object on which to stop listening to the event. |
type | string | Array.<string> | The type of event or the array of types of events you want to stop listening to. |
listener | function | Object | null | The listener to be removed. |
capture | boolean | In DOM-compatible browsers this parameter defines if the listener is called in the capture or in the bubble phase of the event. Learn more about capturing https://javascript.info/bubbling-and-capturing |
handler | Object | The element in scope of which the listener is called. |
Returns:
boolean - Shows if the removed listener existed.Try it:
unlistenByKey
Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().
Params:
Name | Type | Description |
---|---|---|
key | Object | The key returned by listen() for this event listener. |
Returns:
boolean - Indicating whether the listener was there to remove.Try it: