私の回転ゲーム: ビューソース: http://driptone.com/jony/applications/luckyspin/
前の質問 (アニメーションについて説明します): CSS 糸車は 5 秒後に停止しますか?
「スピン」をクリックしてください。ホイールが回転します。
ある時点で、ホイールがゆっくりと停止し始め、アニメーションに MS をゆっくりと追加して、非常に遅くなるようにしたいと考えています。
画像を再設定せずに作ることは可能ですか?再設定とは、つまり、ホイールが現在 440 度で回転している場合、0 度にリセットせずに回転を遅くします。
それは可能ですか?
生成された数字が表示された直後にゆっくりと停止することを考慮して、Javascriptも使用できるようにします(AJAX応答が到着します)
元の JAVASCRIPT コード:
function spinWheel() {
$(".wheel").html("<div class='wheel_spin_on'></div>");
}
function stopWheel() {
$(".wheel").html("<div class='wheel_spin' onClick='loadLuck();'></div>");
}
var timeoutID = '';
function loadLuck() {
clearTimeout(timeoutID);
spinWheel();
$("#luck").html('Spinning......');
timeoutID = setTimeout(function() {
$.post('ajax.php', {getLuck : '1'}, function(data) {
$("#luck").html(data);
stopWheel();
});
}, 3000);
}
CSS コード:
.wheel_spin {
background-image: url("../img/spin2.png");
background-repeat: no-repeat;
width: 262px;
height: 261px;
margin-left: 1%;
}
.wheel_spin_finished {
background-image: url("../img/spin.png");
background-repeat: no-repeat;
width: 262px;
height: 261px;
margin-left: 1%;
}
.wheel_spin_on {
background-image: url("../img/spin.png");
background-repeat: no-repeat;
width: 262px;
height: 261px;
margin-left: 1%;
-webkit-animation-name: spin;
-webkit-animation-duration: 500ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: spin;
-moz-animation-duration: 500ms;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: spin;
-ms-animation-duration: 500ms;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: spin;
animation-duration: 500ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@-ms-keyframes spin {
from { -ms-transform: rotate(0deg); }
to { -ms-transform: rotate(360deg); }
}
@-moz-keyframes spin {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); }
}
@-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
from {
transform:rotate(0deg);
}
to {
transform:rotate(360deg);
}
}