预加载图片的插件
/*
* jQuery Rawr Sliding Container (RSC) v1.0
* Website: http://hungred.com
* Demo Site: http://hungred.com/wp-content/demo/RSC/demo-RSC.html
* Description: A simple sliding container that can be useful for you.
* Contact: clay@hungred.com
* version 1.0
*
* TERMS OF USE - Rawr Sliding Container (RSC)
* Open source under the MIT License.
* Copyright (c) 2009 Clay Lua Czee Yong
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*
*/
(function($){
$.fn.RSC= function(options) {
var defaults = {
prevImageID: "#prev",
nextImageID: "#next",
noOfContainer: 6,
containerW: 500,
duration: 1000
};
var op = $.extend(defaults, options);
var pathObj = $('#container').children();
var i = 0;
function loadImg(url, obj, loading, msg)
{
$(loading).css({"display":"block"}).animate({opacity:1},1000); //display the loading in progress image
$(obj).html("<img src='"+url+"' width='500px' height='350px'/>").css({opacity: 0}); //throw in the image into the div block
var tmp = $(obj).children(); //gets the image obj we just thrown in
tmp[0].onload = function(){ //when the image has complete loaded
$(obj).animate({opacity:1},1000); //display the image
$(loading).animate({opacity:0},1000).css({"display":"none"}); //hide the loading in progress image
}
tmp[0].onerror = function(){ //when the image fail to load for various reason
$(this).css({"display":"none"}); //we hide the image that fail
$(obj).html($(obj).html()+"<div>"+msg+"</div>").animate({opacity:1},1000);//provides a message to the user instead
$(loading).animate({opacity:0},1000).css({"display":"none"}); //hide the loading in progress image
}
}
function getImg(obj)
{
url = $(obj).css({"display":"block", "visibility":"visible"}).html(); //get the image url from the div block
loaded = false; //check whether image has been loaded
if(url.search(/<.*/) != -1) //search for opening tag, doing /'<img.*/>'/ doesn't work in IE7 and Opera somehow.
{
loaded=true; //found opening tag, assume its loaded
tmp = $(obj).children(); //get the img tag obj
url = $(tmp[0]).attr("src"); //retrieve the url
if(tmp[1] != undefined) //check whether there is a second block in the children of the div block (this is added in loadImg when it fail)
loaded = false; //there is an error message, we try to load again
}
if(!loaded)
loadImg(url,obj, "#loading", "there seems to be an issue, try again later");
}
getImg(pathObj[0]);
return this.each(function() {
$(this).click(function()
{
if(this.id==op.prevImageID.replace("#",""))
{
i++;
if(i > 0)
i=(0-(op.noOfContainer-1))
}
else if(this.id==op.nextImageID.replace("#",""))
{
i--;
if(i<(0-(op.noOfContainer-1)))
i=0;
}
$("div#container").animate({marginLeft: i*op.containerW+"px"},op.duration, function(){
var imgObj = getImg(pathObj[0-i]);
});
});
});
};
})(jQuery);
demo:https://hungred.com/wp-content/demo/jQuery-preloading-with-image/demo.html
图片占位、背景图的plugin
http://holderjs.com/
分享到:
相关推荐
、CSS和JavaScript知识的开发者,内容覆盖了jQuery知识体系的全部内容,包括jQuery Core、jQuery Plugin 、jQuery UI、jQuery Mobile以及大量第三方的插件库和2800多个应用jQuery技术的网页参考。
3. **图片预加载**:为了确保用户能够快速地查看大图,插件可能包含图片预加载机制。预加载会预先加载下一张图片,这样当用户切换图片时,新图片已经准备就绪,可以立即显示,提高用户体验。 4. **CSS和HTML结构**...
jquery 的经典 英文书 jQuery Plugin Development Beginner’s Guide.PDF
jQuery Media Plugin是一款专门为jQuery设计的多媒体插件,用于在网页中轻松集成音频、视频和图像等多媒体元素。这款插件的出现,极大地简化了开发者在HTML5时代处理多媒体内容的复杂性,使得开发者无需深入了解...
jQuery plugin for autocomplete - jQuery自动完成插件
3. **初始化插件**:在文档加载完成后,使用jQuery选择器找到标记的图片,并调用`.fancybox()`方法进行初始化。 4. **自定义配置**:根据需求,可以传递参数给`.fancybox()`方法,如设置宽度、高度、动画效果、标题...
同时,Lightbox Plugin还支持自定义设置,如调整预加载图、改变导航箭头样式、设置图片边距等,以适应各种设计需求。 在提供的文件中,`demo.html`是一个示例页面,展示了如何集成和使用Lightbox Plugin。开发者...
5. **预加载机制**:Orbit 插件有智能预加载机制,确保用户在切换到下一幅图片时能流畅地查看,避免了加载延迟的问题。 6. **多种过渡效果**:提供多种过渡动画效果,如淡入淡出、滑动等,增加视觉吸引力。 7. **...
表格拖拽排序插件 Table Drag and Drop JQuery plugin v0.7 最新0.7版本
2. **Lightbox效果**:Lightbox效果是指当用户点击一张缩略图时,图片会在当前页面上以全屏或半透明背景的形式显示,提供了一种沉浸式的查看体验。jQuery Lightbox插件实现了这一功能,同时支持图片预加载、导航箭头...
可选JS库文件:增强图片显示特效可使用jQuery插件Easing Plugin库文件 素材准备 可自定义CSS样式,控制jQuery插件jQuery Image Flyout提示小图片显示效果。 实例代码 一,包含文件部分 [removed][removed] ...
1. **图片加载问题**:如果幻灯片中的图片是异步加载的,可能需要使用`load`事件确保图片加载完成后再启动Cycle。 2. **兼容性问题**:尽管jQuery Cycle Plugin在大多数现代浏览器中表现良好,但在一些旧版本或...
struts2-jquery-plugin-3.1.0.jar
**jQuery摄像头插件jquery-webcam-plugin** 在网页开发中,集成摄像头功能可以帮助用户实时捕捉图像,广泛应用于在线证件照上传、视频聊天、虚拟试衣间等场景。`jQuery webcam plugin`是一个优秀的JavaScript库,它...
aptana jquery plugin js javascript
综上所述,jQuery焦点图图片轮换涉及了jQuery库的使用、DOM操作、事件处理、动画效果、定时器应用等多个JavaScript和Web开发的重要方面。掌握这些技能,不仅可以制作出吸引人的焦点图,还能提升整个网站的用户体验。
* usage as: * var slider = $.fn.jSlider({...}); * slider.setSliderValue(value,callback);
7. **图像资源**: `images`文件夹可能包含插件所需的背景图片、图标或者其他视觉元素,用于美化菜单或者指示状态。根据插件的设计,这些图像可能会被CSS引用或者直接内联在HTML中。 8. **事件处理**: promptuMenu...