Firefox 퀀텀에 애니메이션 문제가 있습니다.Firefox의 애니메이션 문제 퀀텀
애니메이션 요소가 display: none;
인 페이지를 처음로드 할 때 스크립트에서 .display = "block";
으로 전환하면 전체 애니메이션 또는 몇 초가 걸리는 경우 시작 부분을 놓칠 수 있습니다. 아래의 코드 조각에서
보기를 :
var anims = document.getElementsByClassName("anim"),
button$ = document.getElementById("button$"),
time = document.getElementById("time"),
interval = null;
function animate() {
for (var i = 0; i < anims.length; i++)
anims[i].style.display = "block";
}
function timer(sec) {
time.textContent = sec--;
interval = setInterval(function() {
time.textContent = sec >= 0 ? sec-- : clearInterval(interval) || "";
}, 1000);
}
// Directly after click
button0.addEventListener("click", animate);
// One seconds after click
button1.addEventListener("click", function() {
timer(1);
setTimeout(animate, 1000);
});
// Two seconds after click
button2.addEventListener("click", function() {
timer(2);
setTimeout(animate, 2000);
});
// Three seconds after click
button3.addEventListener("click", function() {
timer(3);
setTimeout(animate, 3000);
});
// Hide the divs
reset.addEventListener("click", function() {
for (var i = 0; i < anims.length; i++)
anims[i].style.display = "none";
});
body {
font-family: arial;
}
body > div {
margin-bottom: 10px;
}
#result {
background-color: #e5f3ff;
height: 120px;
padding: 10px;
}
.anim {
display: none;
float: left;
margin: 10px;
width: 50px;
height: 50px;
border-radius: 5px;
animation: animate 1.5s;
}
#anim1 {
background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
/* Only one iteration iteration (default) */
/* This one will not be animated */
}
#anim2 {
background-color: #fddb92;
animation-iteration-count: 3;
/* Three iterations */
/* Only one iteration will be seen */
}
#anim3 {
background-image: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
animation-iteration-count: infinite;
/* Infinite */
/* No visible problem */
}
@keyframes animate {
50% {
transform: translate(80%, 100%) rotate(-360deg);
}
}
<div>
<span><strong>Reload the snippet</strong>
before clicking another button for viewing the issue
<br/><strong>Or,</strong>
<em>Reset</em> (display: "none") before clicking a button to view with no issue: </span>
</div>
<div>
<button id="button0">On click</button>
<button id="button1">1 sec timeout</button>
<button id="button2">2 sec timeout</button>
<button id="button3">3 sec timeout</button>
<button id="reset">Reset</button>
<span id="time"></span>
</div>
<div id="result">
<div id="anim1" class="anim"></div>
<div id="anim2" class="anim"></div>
<div id="anim3" class="anim"></div>
</div>
당신은 무한한 애니메이션은 분명히 문제가없는 것을 알 수 있지만, 다른 두가 분명하지.
그런 다음 해결책은 무엇입니까?
참고 : 당신은이를보기 위해 파이어 폭스 양자를 사용할 필요가
- .
- Google 크롬에서 동일한 스 니펫을 시도했으며 모든 것이 잘 작동합니다.
내가보기에는 파이어 폭스는 처음에는 디스플레이 상태를 보지 않으며 'display : none'이더라도 애니메이션을 실행합니다. 디스플레이 상태에 의존하는 대신 애니메이션 속성을 사용하여 클래스를 설정하는 것이 해결책입니다. –
@ René 수업을 다 했는데도 마찬가지입니다. – theAlexandrian