-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_listeners.js
58 lines (36 loc) · 1.79 KB
/
event_listeners.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// EVENT LISTENERS
// methods that attach "event handlers" (e.g. "click"), to a specified HTML element or DOM object (e.g window object)
// you can add more than one event handler to an element without overwriting existing event handlers
// makes it easier to control how the event reacts to bubbling
//SYNTAX
// addEventListener(typeofevent, function)
// removeEventListener() removes an event listener
// 7 MAIN TYPES OF EVENT LISTENERS
// 1) User Interface Event listeners
// these events occur with browser window as opposed to HTML page
// i.e. the event listners are attached to window object not document object
// load, unload, error, resize, scroll
// 2) Focus & blur Event Listeners
// occur with HTML elements that gain/lose focus when interacted with
// typically used in forms
// focus, blur, focusin, focusout
// 3) Mouse Event Listners
// occur when the user uses the mouse to interact
// uses the bubbling approach
// click, dblclick, mouseover, mouseout, mousedown, mouseup, mousemove
// 4) Keybaord Event Listeners
// occur when the user uses the keyboard to interact
// input, keydown, keypress, keyup
// 5) Form Event Listeners
// common while using forms on a webpage
// submit, change, input
// 6) Mutation Events & Observers
// As the structure of the DOM tree changes, it triggers a "mutation event"
// i.e. am addition or removal of a DOM node through your script
// these have an alternative that will replace them, which are "mutation observers"
// DOMNodeInserted, DOMNodeRemoved, DOMSubtreeModified, DOMNodeInsertedIntoDocument, DOMNodeRemovedFromDocument
// 8) CSS Event Listeners
// trigger when the script encounter a CSS element
// allows JS to work more easily with CSS
// animationstart, animationiteration, animationend
// For example on event listeners, see DRUM KIT repo.