[英]What's the best way to prevent a browser from displaying images until they are fully loaded?
I would like to set up a lean and mean image gallery, with thumbnails displayed inline. 我想建立一个精简和平均的图片库,缩略图显示为内联。 I'd like them not to windowshade in while loading, I'd like them to simply pop up or, if there's a way to detect their completion, use a jQuery effect like a quick fadeIn().
我希望他们在加载时不要使用windowshade,我希望它们只是弹出,或者,如果有办法检测它们的完成,请使用jQuery效果,如快速fadeIn()。
I imagine a line of code like: 我想象一行代码如下:
$(".thumb-image").whenLoaded(fadeIn(500));
$( “拇指图像”)whenLoaded(淡入(500))。
But is there such an event? 但是有这样的事件吗? What's it called?
它叫什么?
jQuery: jQuery的:
$(window).load(function(){
// your code for images....
});
Or Vanilla JavaScript: 或香草JavaScript:
window.onload = function(){
// your code for images....
};
The load
event fires after all images, DOM, external resources, frames, etc have loaded. load
所有图像,DOM,外部资源,框架等后,将触发load
事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.