forked from wesbos/JavaScript30
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
18 lines (15 loc) · 872 Bytes
/
script.js
File metadata and controls
18 lines (15 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';
const inputs = document.querySelectorAll('.controls input');
function handleEvent() {
// this = input sur lequel l'évènement a été déclenché.
//using dataset to retreive personnal html attribute
const sizing = this.dataset.sizing || '';
// magic line
/* The Document.documentElement read-only property returns the Element that is the root element of the document
(for example, the <html> element for HTML documents).*/
/* The HTMLElement.style property returns a CSSStyleDeclaration object that represents only the element's inline style attribute,
ignoring any applied style rules */
document.documentElement.style.setProperty(`--${this.name}`, this.value + sizing);
}
inputs.forEach(input => input.addEventListener('change', handleEvent));
inputs.forEach(input => input.addEventListener('mousemove', handleEvent));