请在下面找到 jsfiddle 以供参考
Javascript (FF)
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";
var counter = 0;
c.addEventListener('DOMMouseScroll',function(event){
draw();
return false;
}, false);
function draw(){
var j = ++counter;
for(var i = 0; i < 10000; i++){
ctx.clearRect(0, 0, c.width, c.height);
ctx.fillText("Hello World " + j ,10,50);
}
}
Javascript(铬)
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";
var counter = 0;
c.addEventListener('mousewheel',function(event){
draw();
return false;
}, false);
function draw(){
var j = ++counter;
for(var i = 0; i < 10000; i++){
ctx.clearRect(0, 0, c.width, c.height);
ctx.fillText("Hello World " + j ,10,50);
}
}
HTML
<!DOCTYPE html>
<html>
<body>
<span>Scroll on below canvas</span>
<br/>
<canvas id="myCanvas" width="600" height="100" style="border:5px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
</body>
</html>
现在尝试在上面的 fiddles 的画布上使用 mouseWheel 快速滚动,您会发现在 Firefox 中跳过了数字,而 Google Chrome 可以流畅地渲染而不会跳过数字。
如何在 Firefox 浏览器中进行类似于 Google Chrome 的渲染?