-
Notifications
You must be signed in to change notification settings - Fork 0
/
articulate-rive-wolken.html
52 lines (44 loc) · 1.54 KB
/
articulate-rive-wolken.html
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
<!DOCTYPE html>
<html>
<head>
<title>Wolken</title>
<meta charset="UTF-8" />
</head>
<body>
<canvas id="canvas" width="100" height="100"></canvas>
<!-- Rive script -->
<script src="https://unpkg.com/@rive-app/[email protected]"></script>
<script>
// load Rive anumation
const r = new rive.Rive({
src: './articulate-rive-wolken.riv',
canvas: document.getElementById('canvas'),
autoplay: true,
stateMachines: 'State Machine 1',
layout: new rive.Layout({fit: rive.Fit.Contain }),
onLoad: (_) => {
// Get the inputs via the name of the state machine
const inputs = r.stateMachineInputs('State Machine 1');
// Find the input you want to set a value for, or trigger
const isCloudy = inputs.find(i => i.name === 'Cloudy');
// Gebruik localstorage
window.addEventListener('storage', (event) => {
// Als mood in de storage verandert dan ...
if (event.storageArea === sessionStorage && event.key === 'weather') {
switch (sessionStorage.getItem('weather')) {
case "cloudy":
console.log("Weather is cloudy");
isCloudy.value = true;
break;
default:
console.log("Not cloudy");
isCloudy.value = false;
break;
}
}
});
}
});
</script>
</body>
</html>