jquery预加载图像在翻转时闪烁

时间:2015-02-14 22:15:40

标签: jquery

我完全复制了这个小jquery预加载器[可能来自这里的答案]

现在工作得很好,但是现在:

  • 当鼠标第一次出现时,图像将从正常状态闪烁到空白状态到鼠标悬停状态和鼠标输出
  • 随后的鼠标工作正常。
  • 在网络检查器中,我可以看到他们正在加载页面但是在鼠标悬停时会再次加载。条目如下:

    image.jpg GET 200 image / jpeg jquery.min.js

以下是预加载脚本和翻转脚本:

// preloading
var loadimages = [];

$('.preload-image').each(function(i){
    loadimages[i] = $(this).attr('src');
})

$.fn.preload = function() {
    this.each(function(){
       $('<img/>')[0].src = this;
    });
}

$([loadimages]).preload();
// preloading


// category tile rollovers
$( ".category-cell-link" )
    .mouseover(function() {
        var id = $(this).attr('id');
        var rollover = '/Assets/Images/shopbybike/' + id + '-over.jpg';
        var style = 'background:transparent url(' + rollover + ')no-repeat 0 0;'
        $(this).attr("style", style);
        })
    .mouseout(function() {
        var id = $(this).attr('id');
        var rollout = '/Assets/Images/shopbybike/' + id + '.jpg';
        var style = 'background:transparent url(' + rollout + ')no-repeat 0 0;'
        $(this).attr("style", style);
    });

这确实在没有闪烁效果的情况下工作,但是在工作之后我没有更改任何代码。

不确定为什么会这样,有人能看到我遗失/做错了什么吗?

实例:woodcraft

0 个答案:

没有答案
相关问题