简体   繁体   English

Firefox中的skrollr背景图像闪烁

[英]skrollr background image flicker in Firefox

I have a div with a background image. 我有一个带背景图像的div。 Using skrollr, I'm changing the background image, getting sort of an animation (paper airplaine folding up). 使用skrollr,我正在更改背景图像,得到一种动画效果(折叠纸张airplaine)。 to prevent interpolation, I use a custom easing function: 为了防止插值,我使用了自定义缓动函数:

easeInt: function(p) {
   return Math.floor(p * 13) / 13;
}

My animation looks like this (skrollr-stylesheet): 我的动画如下所示(skrollr样式表):

3528 {
    background-image[easeInt]: url("img/plane14/plane0.png");
}

3928 {
    background-image[easeInt]: url("img/plane14/plane13.png");
}

When the animation's running, the background image disappears for a bit before the next one appears, causing the animation to flicker. 动画运行时,背景图像消失一会,然后下一个图像出现,从而使动画闪烁。 This issue only shows up in Firefox, not in Chrome or Safari. 仅在Firefox中会显示此问题,而在Chrome或Safari中不会显示此问题。 I am preloading all the images using 我正在使用预加载所有图像

var img1 = new Image(); img1.src = 'img/plane14/plane1.png';

Preloading all the images using HTML didn't do the job either: 使用HTML预加载所有图像也无法完成该工作:

<div style="width:100px; height:100px; position: fixed; top: -100px; left: -100px;">
<!-- loading all images as <img src="imageurl.png"> -->
</div>

I also tried using skrollr's option of preventing interpolation. 我也尝试使用skrollr的选项来防止插值。 Already checked my easing function, it should work properly. 已经检查了我的缓动功能,它应该可以正常工作。 In firebug I can observe that the background-image is being changed as desired. 在萤火虫中,我可以观察到背景图像正在按需更改。 Still I get this flickering. 还是我忽隐忽现。

I am not familiar with Skrollr but I have been looking into a similar situation with images flickering when they have been swapped. 我对Skrollr并不熟悉,但是我一直在研究类似的情况,当交换它们时,图像会闪烁。

My understanding of the issue is that Firefox doesn't decode the images until they are viewed for the first time and the flicker you are seeing is the image trying to display before the decode is ready. 我对此问题的理解是,Firefox不会在第一次查看图像之前对其进行解码,而您所看到的闪烁是试图在解码准备就绪之前显示的图像。 Loading the image is separate to the decode so that is why preloading has no effect on this issue for Firefox. 加载图像与解码是分开的,因此这就是为什么预加载对于Firefox在此问题上没有影响的原因。

If you go to about:config in Firefox its possible to change the setting image.decode-immediately.enabled and this should fix the issue locally. 如果您在Firefox中转到about:config,则可以更改设置image.decode-immediately.enabled,这应该可以在本地解决此问题。 Unfortunately I haven't found a better way to solve this issue. 不幸的是,我还没有找到解决此问题的更好方法。

I found several bugzilla cases I believe are related to this issue: 我发现了一些Bugzilla案例,我相信与该问题有关:

https://bugzilla.mozilla.org/show_bug.cgi?id=1149893 https://bugzilla.mozilla.org/show_bug.cgi?id=1149893

https://bugzilla.mozilla.org/show_bug.cgi?id=1158440 https://bugzilla.mozilla.org/show_bug.cgi?id=1158440

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM