简体   繁体   English

延迟加载背景图片/淡入淡出替换背景图片

[英]Lazyloading Background Images / FadeIn replacing Background-image

I am building a site which uses the Maximage jquery plugin to run a background image slideshow. 我正在建立一个使用Maximage jquery插件运行背景图像幻灯片放映的网站。 Due to the size of the images, I've decided to try and implement a lazyloading approach which will replace the lower quality images with higher quality images which have been downloaded in the background. 由于图像的大小,我决定尝试实施惰性加载方法,该方法将用较低质量的图像替换为在后台下载的较高质量的图像。

The code works, but the issue is that there is a an obvious flash as the background-image src of the maximage slide is changed to point to the higher quality image. 该代码有效,但是问题在于,随着maximage幻灯片的background-image src更改为指向更高质量的图像,明显出现了闪光。

I'm not sure how to solve this problem, is there a way to fadeIn replace the background-image of a div? 我不确定如何解决此问题,有没有一种方法可以淡入淡出替换div的背景图像?

Thanks for any help. 谢谢你的帮助。

Could you write it in such a way that once the high quality image is done loading, instead of replacing the low quality image, insert the high quality into DOM as a hidden DIV or something like that. 您能以这样一种方式编写它吗:一旦完成高质量图像的加载,而不是替换低质量图像,而是将高质量图像作为隐藏的DIV插入DOM中。

Then fade out the low quality wrapper DIV as you fade in the high quality wrapper DIV (ie. simultaneous animations) at as the callback for animation finish, detach/hide the low quality DIV. 然后在淡出高质量包装器DIV(即同时动画)时淡出低质量包装器DIV,作为动画完成的回调,分离/隐藏低质量DIV。 That might still cause a flicker in some browsers/devices though, I'd have to setup a demo or something to see. 尽管这可能仍会在某些浏览器/设备中引起闪烁,但我必须设置一个演示或其他内容才能看到。

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

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