Jquery 简单间谍不缓存映像
简单间谍是非常有用的jquery插件/代码!但我看到这不是缓存图像和发送许多请求到服务器!有人知道有什么问题吗 间谍代码:Jquery 简单间谍不缓存映像,jquery,caching,Jquery,Caching,简单间谍是非常有用的jquery插件/代码!但我看到这不是缓存图像和发送许多请求到服务器!有人知道有什么问题吗 间谍代码: $(function () { $('ul.spy').simpleSpy(); }); (function ($) { $.fn.simpleSpy = function (limit, interval) { limit = limit || 4; interval = interval || 4000; return this.e
$(function () {
$('ul.spy').simpleSpy();
});
(function ($) {
$.fn.simpleSpy = function (limit, interval) {
limit = limit || 4;
interval = interval || 4000;
return this.each(function () {
// 1. setup
// capture a cache of all the list items
// chomp the list down to limit li elements
var $list = $(this),
items = [], // uninitialised
currentItem = limit,
total = 0, // initialise later on
height = $list.find('> li:first').height();
// capture the cache
$list.find('> li').each(function () {
items.push('<li>' + $(this).html() + '</li>');
});
total = items.length;
$list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
$list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();
// 2. effect
function spy() {
// insert a new item with opacity and height of zero
var $insert = $(items[currentItem]).css({
height : 0,
opacity : 0
}).prependTo($list);
// fade the LAST item out
$list.find('> li:last').animate({ opacity : 0}, 1000, function () {
// increase the height of the NEW first item
$insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
// AND at the same time - decrease the height of the LAST item
// $(this).animate({ height : 0 }, 1000, function () {
// finally fade the first item in (and we can remove the last)
$(this).remove();
// });
});
currentItem++;
if (currentItem >= total) {
currentItem = 0;
}
setTimeout(spy, interval)
}
spy();
});
};
})(jQuery);
$(函数(){
$('ul.spy').simpleSpy();
});
(函数($){
$.fn.simpleSpy=函数(限制、间隔){
极限=极限| | 4;
间隔=间隔| | 4000;
返回此。每个(函数(){
//1.设置
//捕获所有列表项的缓存
//将列表缩小以限制li元素
var$list=$(此),
items=[],//未初始化
currentItem=限制,
总计=0,//稍后初始化
height=$list.find('>li:first').height();
//捕获缓存
$list.find('>li')。每个(函数(){
items.push(''+$(this.html()+' ');
});
总计=项目长度;
$list.wrap(“”).parent().css({height:height*limit});
$list.find('>li').filter(':gt(+(limit-1)+')).remove();
//2.效果
函数spy(){
//插入不透明度和高度为零的新项目
var$insert=$(items[currentItem]).css({
高度:0,,
不透明度:0
}).prependTo($清单);
//淡出最后一项
$list.find('>li:last').animate({opacity:0},1000,function(){
//增加新的第一项的高度
$insert.animate({height:height},1000)。animate({opacity:1},1000);
//同时,降低最后一项的高度
//$(this).animate({height:0},1000,function(){
//最后淡入第一项(我们可以删除最后一项)
$(this.remove();
// });
});
currentItem++;
如果(当前项>=总计){
currentItem=0;
}
设置超时(间谍,间隔)
}
间谍();
});
};
})(jQuery);
原始来源:
演示Ib JSFIDLE:
萤火虫图片:
XXXXX圣诞节XXXXX只需将图像预加载添加到脚本中即可。
你可以在这里找到很好的例子:Firebug图像我刚刚检查过。在检查后,它实际上会缓存它们请稍等!你看。看火虫图片是的,我现在就看。这是因为在这个脚本中没有图像预加载,在你看来,应该怎么做?!是 啊这是一个完美的解决方案,但具体位置和方式如何