-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvg.js
35 lines (30 loc) · 760 Bytes
/
svg.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
const svgGameState = {
running: false,
};
const startSvgGame = () => {
$("#svg-obstacle-animation")
.attr("repeatCount", "indefinite")[0]
.beginElement();
$("#svg-start-text").css("opacity", "0");
svgGameState.running = true;
};
const stopSvgGame = () => {
$("#svg-obstacle-animation").attr("repeatCount", "1")[0].endElement();
};
$("#svg-button").click(function () {
if (svgGameState.running) {
$("#svg-penguin-jump-animation")[0].beginElement();
} else {
startSvgGame();
}
});
$("#svg-button").mousedown(function () {
$("#svg-button").attr("r", 30 * 0.9);
});
$("#svg-button").mouseup(function () {
$("#svg-button").attr("r", 30 * 1);
});
$("#svg-box").on({
mouseenter: startSvgGame,
mouseleave: stopSvgGame,
});