FF 中画布图像滚动性能

发布于 2024-12-28 15:36:50 字数 980 浏览 1 评论 0原文

我在 FF 中遇到了严重的性能问题。

这是代码:

JS:

var img = new Image();  
img.src = 'image.jpg'; 

var w = $(window).outerWidth();
var h = $(window).height();

var addit = -1;
var scrollSpeed = 10; //fast in IE, but very slow in FF
var current = 0;

ctx = document.getElementById('canvas1').getContext('2d');

var init = setInterval(function(){
        current += addit;
        ctx.drawImage(img,current,0, w, h);
           }, scrollSpeed);

CSS:

    #canvas1 {
        width:auto;
        height:100%;
        position: absolute;
        top: 0;
        left: 0;
    }
    body {
        overflow: hidden;
    }

HTML:

<body>
 <canvas id="canvas1" width="1784px" height="534px"></canvas>
</body>

image.jpg is 1784x534px

任何人都可以帮我得到FF 和 IE 的性能一样吗? 我尝试过使用 CSS left 属性,但性能仍然很慢。 谢谢你!

I am having a terrible performance issue in FF.

Here is the code:

JS:

var img = new Image();  
img.src = 'image.jpg'; 

var w = $(window).outerWidth();
var h = $(window).height();

var addit = -1;
var scrollSpeed = 10; //fast in IE, but very slow in FF
var current = 0;

ctx = document.getElementById('canvas1').getContext('2d');

var init = setInterval(function(){
        current += addit;
        ctx.drawImage(img,current,0, w, h);
           }, scrollSpeed);

CSS:

    #canvas1 {
        width:auto;
        height:100%;
        position: absolute;
        top: 0;
        left: 0;
    }
    body {
        overflow: hidden;
    }

HTML:

<body>
 <canvas id="canvas1" width="1784px" height="534px"></canvas>
</body>

image.jpg is 1784x534px

Can anybody help me get the same performance in FF as IE?
I have tried to use CSS left property but performance is still slow.
Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沒落の蓅哖 2025-01-04 15:36:50

经过对硬件加速的一些调查后;我注意到 Firefox“about:support”中“Direct2D Enabled”被错误版本的图形驱动程序阻止。

我更新了它,现在由于硬件加速,速度变得更快了。

after some investigation into hardware acceleration; I noticed in Firefox "about:support" that "Direct2D Enabled" was blocked by a wrong version graphics driver.

I updated it, and now things are much faster thanks to hardware acceleration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文