-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
99 lines (74 loc) · 2.4 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
console.clear();
// CSS paint backgrounds - these are on the body and I want them changed every slide change
CSS.paintWorklet.addModule('dots.js');
// change background colours ====================
const revealOuter = document.querySelector('.reveal');
// props & vals =========================
// register property
CSS.registerProperty({
name: '--lighterMain',
syntax: '<color>',
initialValue: 'lightblue',
inherits: true
})
// quick and dirty -> with hsla - set main colour, create and set lighter colour
function setCols(hslaString) {
revealOuter.style.setProperty('--mainColour', hslaString)
// return split hsla
const splitCol = colFromHsla(hslaString);
splitCol.lum = splitCol.lum+10;
// create lighter col
const lighterCol = `hsla(${splitCol.hue}, ${splitCol.sat}%, ${splitCol.lum}%, ${splitCol.op})`;
revealOuter.style.setProperty('--lighterMain', lighterCol);
}
Reveal.addEventListener('purple', () => {
setCols('hsla(273, 36%, 64%, 1)');
})
Reveal.addEventListener('blue', () => {
setCols('hsla(179, 38%, 58%, 1)');
})
Reveal.addEventListener('pink', () => {
setCols('hsla(346, 63%, 64%, 1)');
})
Reveal.addEventListener('orange', () => {
setCols('hsla(5, 74%, 67%, 1)');
})
Reveal.addEventListener('green', () => {
setCols('hsla(131, 30%, 63%, 1)');
})
// console log typen om ======================
const buttonEl = document.querySelector('.button');
Reveal.addEventListener('style', () => {
console.clear();
console.log("4px");
})
Reveal.addEventListener('typed', () => {
console.clear();
const width = buttonEl.computedStyleMap().get('border-top-width')
console.log(width);
})
Reveal.addEventListener('make', () => {
console.clear();
document.querySelector('#butt').attributeStyleMap.set('border-top-width', CSS.px(10));
console.log(document.querySelector('#butt').attributeStyleMap.get('border-top-width'));
})
// register a property to animate
CSS.registerProperty({
name: '--animatedCol',
syntax: '<color>',
initialValue: 'transparent',
inherits: false
})
function colFromHsla(hslaString) {
let sep = hslaString.indexOf(",") > -1 ? "," : " ";
hslaString = hslaString.substr(5).split(")")[0].split(sep);
if (hslaString.indexOf("/") > -1)
hslaString.splice(3,1);
let col = {
hue: Number(hslaString[0]),
sat: Number(hslaString[1].substr(0,hslaString[1].length - 1)),
lum: Number(hslaString[2].substr(0,hslaString[2].length - 1)),
op: Number(hslaString[3])
}
return col;
}