對項目的一些洞察: 一個完整的交互式網站,動畫將播放..然後他們會停下來,一旦他們停止並且動畫發生了一個鼠標懸停事件,它會播放直到70%的動畫是完整的,當點擊另一個對象(在這種情況下是文本),它將完成它的循環。CSS動畫在Chrome中不起作用
我的項目合作伙伴在Google網頁設計師製作了動畫,我們已經爲我們的項目嘗試了多個程序,例如Adobe Edge,但不幸的是,由於我們動畫的大小,我們無法使用SVG或PNG序列,同樣的spritesheets ..所以我們到達css動畫,不幸的是我的css動畫的知識是非常有限的,我想知道如果有人能夠幫助我。
我有一個問題:爲什麼我的CSS動畫在Chrome中的行爲與Firefox中的行爲不一樣?
我已經嘗試了以下解決方案,並看着下面的帖子:
- css3 animation not working in chrome
- CSS Animation not working on Chrome
- Chrome Keyframe animation not working
的jQuery:
<script>
$(document).ready(function(){
//$('.gwd-img-r1sa').toggle(function() {
// $('.gwd-img-r1sa').css({"animation-play-state":"paused","-webkit-animation-play-state":"paused"});
//}, function() {
// $('.gwd-img-r1sa').css({"animation-play-state":"running","-webkit-animation-play-state":"running"});
//});
$(".gwd-img-r1sa").on("mouseenter", function(){
$(".gwd-img-r1sa").css({"animation-iteration-count":"0.7", "-webkit-animation-iteration-count":"0.9"});
});
$("#play").on("click", function(){
$(".gwd-img-r1sa").css({"animation-iteration-count":"1", "-webkit-animation-iteration-count":"1"});
});
});
</script>
個CSS:
<style type="text/css">
/**.gwd-img-r1sa:hover, .gwd-img-r1sa:focus
{
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
**/
html, body {
width: 100%;
height: 100%;
margin: 0px;
}
body {
background-color: transparent;
-webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
-moz-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
-webkit-perspective: 1400px;
-moz-perspective: 1400px;
perspective: 1400px;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.gwd-img-r1sa {
position: absolute;
width: 192px;
height: 146px;
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
left: 312px;
top: 604px;
-webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
-moz-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
@-webkit-keyframes gwd-empty-animation {
0% { opacity: 0.001; }
100% { opacity: 0; }
}
@-moz-keyframes gwd-empty-animation {
0% { opacity: 0.001; }
100% { opacity: 0; }
}
@keyframes gwd-empty-animation {
0% { opacity: 0.001; }
100% { opacity: 0; }
}
@-webkit-keyframes gwd-gen-hlergwdanimation_gwd-keyframes {
0% { left: 312px; top: 604px; -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -webkit-animation-timing-function: linear; }
30% { left: 595px; top: 350px; -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -webkit-animation-timing-function: linear; }
50% { left: 595px; top: 350px; -webkit-transform: matrix3d(0.0510417556, 0.9986965201, 0, 0, -0.9986965201, 0.0510417556, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -webkit-animation-timing-function: linear;}
100% { left: 595px; top: 350px; -webkit-transform: matrix3d(0.051, 0.9987, 0, 0, -0.9987, 0.051, 0, 0, 0, 0, 1, 0, 312, 146, 0, 1); -webkit-animation-timing-function: linear; }
}
@-moz-keyframes gwd-gen-hlergwdanimation_gwd-keyframes {
0% { left: 312px; top: 604px; -moz-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -moz-animation-timing-function: linear; }
30% { left: 595px; top: 350px; -moz-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -moz-animation-timing-function: linear; }
50% { left: 595px; top: 350px; -moz-transform: matrix3d(0.0510417556, 0.9986965201, 0, 0, -0.9986965201, 0.0510417556, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -moz-animation-timing-function: linear; }
100% { left: 595px; top: 350px; -moz-transform: matrix3d(0.051, 0.9987, 0, 0, -0.9987, 0.051, 0, 0, 0, 0, 1, 0, 312, 146, 0, 1); -moz-animation-timing-function: linear; }
}
@keyframes gwd-gen-hlergwdanimation_gwd-keyframes {
0% { left: 312px; top: 604px; transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); animation-timing-function: linear; }
30% { left: 595px; top: 350px; transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); animation-timing-function: linear; }
50% { left: 595px; top: 350px; transform: matrix3d(0.0510417556, 0.9986965201, 0, 0, -0.9986965201, 0.0510417556, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); animation-timing-function: linear; }
100% { left: 595px; top: 350px; transform: matrix3d(0.051, 0.9987, 0, 0, -0.9987, 0.051, 0, 0, 0, 0, 1, 0, 312, 146, 0, 1); animation-timing-function: linear; }
}
body .gwd-gen-hlergwdanimation {
-webkit-animation: gwd-gen-hlergwdanimation_gwd-keyframes 3s linear 0s 1 normal forwards;
-moz-animation: gwd-gen-hlergwdanimation_gwd-keyframes 3s linear 0s 1 normal forwards;
animation: gwd-gen-hlergwdanimation_gwd-keyframes 3s linear 0s 1 normal forwards;
}
</style>
HTML:
<img src="3ds_preset_gearshape.png" class="gwd-img-r1sa gwd-gen-hlergwdanimation" data-gwd-style="" data-gwd-override-style="" style="animation-iteration-count: 0.1;">
<div id="play">
click here to play
</div>
是否有人可以幫忙嗎?
此外:爲什麼圖像會移動,然後停止..然後在懸停時,它有時會跳到30%,而不是直到30%才玩?跳過70%而不是打到70%也是一樣?
剛剛發現的東西,可以注意值得:
更改:<img src="3ds_preset_gearshape.png" class="gwd-img-r1sa gwd-gen-hlergwdanimation" data-gwd-style="" data-gwd-override-style="" style="animation-iteration-count: 0.1;">
這樣:<img src="3ds_preset_gearshape.png" class="gwd-img-r1sa gwd-gen-hlergwdanimation" data-gwd-style="" data-gwd-override-style="" style="-webkit-animation-iteration-count: 0.1;">
原因動畫的此位在Chrome中工作,但爲什麼沒有它的工作當我在我的文檔的樣式部分中使用它時?
我發[此的jsfiddle(http://jsfiddle.net/Lvq6ee8d/)和(據我可以告訴),它的工作? – 2014-10-27 13:34:12
@MrCoder小提琴也適用於我 – Izzy 2014-10-27 13:35:21
幾件事情可能是潛在的問題。您正在使用jQuery來轉換CSS轉換,以及CSS轉換。我將你的jQuery函數移動到CSS中,像這樣.gwd-img-r1sa:hover另外它奇怪的是你使用了一個小數來計算迭代次數,以及將它分配兩次 – 2014-10-27 13:35:25