namespace Event
Methods
Instance methods
-
element
Event#element() -> Element Event.element(event) -> ElementReturns the DOM element on which the event occurred.
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
findElement
Event#findElement(expression) -> Element Event.findElement(event, expression) -> ElementReturns the first DOM element that matches a given CSS selector — starting with the element on which the event occurred, then moving up its ancestor chain.
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
isLeftClick
Event#isLeftClick() -> Boolean Event.isLeftClick(event) -> BooleanDetermines whether a button-related mouse event involved the left mouse button.
Keep in mind that the "left" mouse button is actually the "primary" mouse button. When a mouse is in left-handed mode, the browser will report clicks of the right button as "left-clicks."
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
isMiddleClick
Event#isMiddleClick() -> Boolean Event.isMiddleClick(event) -> BooleanDetermines whether a button-related mouse event involved the middle mouse button.
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
isRightClick
Event#isRightClick() -> Boolean Event.isRightClick(event) -> BooleanDetermines whether a button-related mouse event involved the right mouse button.
Keep in mind that the "left" mouse button is actually the "secondary" mouse button. When a mouse is in left-handed mode, the browser will report clicks of the left button as "left-clicks."
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
pointer
Event#pointer() -> Object Event.pointer(event) -> ObjectReturns the absolute position of the pointer for a mouse event.
Returns an object in the form
{ x: Number, y: Number}.Note that this position is absolute on the page, not on the viewport.
This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
-
pointerX
Event#pointerX(event) -> NumberReturns the absolute horizontal position of the pointer for a mouse event.
Note that this position is absolute on the page, not on the viewport.
-
pointerY
Event#pointerY(event) -> NumberReturns the absolute vertical position of the pointer for a mouse event.
Note that this position is absolute on the page, not on the viewport.
-
stop
Event#stop() -> undefined Event.stop(event) -> undefinedStops the event’s propagation and prevents its eventual default action from being triggered.
Stopping an event also sets a
stoppedproperty on that event for future inspection.This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.
Class methods
-
fire
Event.fire(element, eventName[, memo[, bubble = true]]) -> Event-
memo(?) – Metadata for the event. Will be accessible through the event'smemoproperty. -
bubble(Boolean) – Whether the event will bubble.
Fires a custom event of name
eventNamewithelementas its target.Custom events must include a colon (
:) in their names. -
-
observe
Event.observe(element, eventName, handler) -> ElementRegisters an event handler on a DOM element.
-
stopObserving
Event.stopObserving(element[, eventName[, handler]]) -> ElementUnregisters one or more event handlers.
If
handleris omitted, unregisters all event handlers onelementfor thateventName. IfeventNameis also omitted, unregisters all event handlers onelement.
