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
|
$("#spin").click(function(e) {
e.preventDefault();
document.getElementById("dice").classList.add("spinning");
rnd = Math.floor(Math.random() * 6 + 1);
let x, y;
switch (rnd) {
case 1:
x = 720;
y = 810;
break;
case 6:
x = 720;
y = 990;
break;
default:
x = 720 + (6 - rnd) * 90;
y = 900;
break;
}
setTimeout(function() {
document.getElementById("dice").classList.remove("spinning");
}, 1000); // Durée de la transition
$(".dice").css(
"transform",
"translateZ(-100px) rotateY(" + x + "deg) rotateX(" + y + "deg)"
);
}); |
Partager