2
在scroll
事件中使用window.requestAnimationFrame
時出現問題。JavaScript在滾動事件上使用requestAnimationFrame
我想用CSS transform:translate3D
document.getElementById("content").addEventListener("scroll", function(){
var getScroll = this.scrollTop * 1.2;
function repeatOften() {
document.getElementById("moveable").style.transform =
"translate3D(0," + getScroll + "px, 0)";
requestAnimationFrame(repeatOften);
}
requestAnimationFrame(repeatOften);
});
檢查這個小提琴移動DIV
:https://jsfiddle.net/tcayv8dp/
爲什麼這個動畫不流暢運行?
我的代碼有什麼問題?
謝謝.....。 。