DOM Object Events Flashcards

(28 cards)

1
Q

AnimationEvent

A

an event for CSS animations
types: animationstart, animationend,
animationiteration (when an animation is repeated)

properties: animationName, elapsedTime,
psuedo-element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ClipboardEvent

A

Events that occur when the clipboard is modified

types: oncopy, oncut, onpaste
property: clipboardData

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

DragEvent

A

Events that occur when elements are dragged and/or dropped. Inherits properties from MouseEvent.

types: ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop
property: dataTransfer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

FocusEvent

A

Events that occur when elements gets or loses focus. Inherits properties and methods from UiEvent.

types: onblur, onfocus
onfocusin (about to get focus)
onfocusout (about to lose focus)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

InputEvent

A

Events that occur when a form element’s content changes. Inherits from UiEvent

type: oninput
properties: data, dataTransfer, getTargetRanges(), inputType, isComposing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

TouchEvent, KeyboardEvent, MouseEvent properties:

altKey, ctrlKey, shiftKey, metaKey

A

Boolean properties that return true if each key was pressed when the event triggered

meta is command/windows key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

KeyboardEvent

A

Events that occur when user presses a key on the keyboard. Inherits from UiEvent

types: onkeydown, onkeypress, onkeyup
properties: code, charCode, key, location, repeat, which

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

MouseEvent

A

Events that occur when the mouse interacts with the HTML document. Inherits from UiEvent

types: onclick, ondblclick, oncontextmenu (M2), onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmousup
properties: clientX, clientY, screenX, screenY, movementX, movementY, offsetX, offsetY, pageX, pageY

client: browser
page: document
offset: target element
screen: user’s screen
movement: relative to prior mouse event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

PageTransitionEvent

A

Events that occur when user navigates to, and away from, a webpage.

types: pagehide, pageshow
property: persisted (was the page cached by the browser)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ProgressEvent

A

Events that occur when loading external resources, belongs to the ProgressEvent Object.

types: onerror, onloadstart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

TouchEvent

A

Events that occur when user touches a touch-based device

types: ontouchcancel, ontouchend, ontouchmove, ontouchstart
properties: touches, targettouches, changedtouches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

TransitionEvent

A

Events that occur when a CSS transition runs

type: transitionend
properties: propertyName, elapsedTime, pseudoElement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

UiEvent

A

Events that are triggered from the user interface.
Childrend of UiEvent: FocusEvent, InputEvent, KeyboardEvent, MouseEvent, TouchEvent, WheelEvent

types: abort, beforeunload, error, load, resize, scroll, select, unload

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

WheelEvent

A

Events that occur when the mouse wheel is scrolling. Inherits from MouseEvent and UiEvent

type: onwheel
properties: deltaX, deltaY, deltaZ, deltaMode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

abort

A

when the loading of media is aborted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

afterprint

A

an event that occurs when a page has started printing or if the print dialogue box has been closed

17
Q

beforeprint

A

an event that occurs when a page is about to be printed

18
Q

canplay

A

an event that occurs when a media has buffered enough to being

19
Q

canplaythrough

A

The event occurs when the browser can play through the media without stopping for buffering

20
Q

change

A

The event occurs when the content of a form element, the selection, or the checked state have changed (for input, select, and textarea)

21
Q

ended

A

The event occurs when the media has reach the end (useful for messages like “thanks for listening”)

22
Q

fullscreenchange

A

The event occurs when an element is displayed in fullscreen mode

23
Q

message

A

The event occurs when a message is received through the event source

24
Q

offline / online

A

The event occurs when the browser starts to work offline / online

25
pause, play, playing
events for when a media is paused of is no longer paused. playing (resumed after pause)
26
submit
The event occurs when a form is submitted
27
What is Event Delegation?
The idea is that if we have a lot of elements handled in a similar way, then instead of assigning a "handler" to each of them We put a single handler on their common ancestor. ``` table.onclick = function(event) { let target = event.target; // where was the click? ``` if (target.tagName != 'TD') return; // not on TD? Then we're not interested highlight(target); // highlight it };
28
How can event Delegation be used on a group of save load and search buttons?
div button data-action="save">Save< /button button data-action="load">Load< /button button data-action="search">Search< /button /div ``` class Menu { constructor(elem) { this._elem = elem; elem.onclick = this.onClick.bind(this); // (*) } ``` save() { alert('saving'); } load() { alert('loading'); } search() { alert('searching'); } ``` onClick(event) { let action = event.target.dataset.action; if (action) { this[action](); } }; } new Menu(menu); ```