-
Notifications
You must be signed in to change notification settings - Fork 52
/
setup.js
66 lines (59 loc) · 1.72 KB
/
setup.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
// EVENTS
let showCursor = true;
const toggleCursorEl = document.querySelector('[data-toggle-cursor]');
toggleCursorEl.addEventListener('click', () => {
showCursor = !showCursor;
if (showCursor) {
toggleCursorEl.innerHTML = 'Show Real Cursor';
document.documentElement.style.cursor = 'none';
} else {
toggleCursorEl.innerHTML = 'Hide Real Cursor';
document.documentElement.style.cursor = 'default';
}
});
if ('ontouchstart' in document.documentElement) {
document.querySelector('.info-description').innerHTML +=
"<div style='color:#c0392b'><b><i>Doesn't work with touchscreens tho... :(</i></b></div>";
}
document.querySelector(`[data-new-random]`).addEventListener('click', (evt) => {
evt.preventDefault();
const amountOfElements =
(Math.random() > 0.8 ? 5 : 2) + Math.floor(Math.random() * 8);
const newConfig = new Array(amountOfElements).fill('').map(() => {
return Math.random() > 0.5
? {
behavior: 'REPEL',
innerHTML: 'Repel',
className: ['clickme', '-nope'],
position: [
Math.floor(Math.random() * 92) + 4,
Math.floor(Math.random() * 92) + 4,
],
}
: {
behavior: 'ATTRACT',
innerHTML: 'Attract',
className: ['clickme'],
position: [
Math.floor(Math.random() * 92) + 4,
Math.floor(Math.random() * 92) + 4,
],
};
});
window.ControlUserCursor(newConfig);
});
// INITIALIZE
window.ControlUserCursor([
{
behavior: 'REPEL',
innerHTML: 'Repel',
className: ['clickme', '-nope'],
position: [60, 33],
},
{
behavior: 'ATTRACT',
innerHTML: 'Attract',
className: ['clickme'],
position: [40, 66],
},
]);