Skip to content

Commit

Permalink
Add simple image preload
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyapps committed Dec 1, 2011
1 parent 0510f2c commit e7d1e16
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/jquery.fancybox.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,21 @@
}));
},

_preload : function() {
var group = F.group,
index = F.current.index,
load = function(href) {
if (href && F.isImage(href)) {
new Image().src = href;
}
};

if (group.length > 1) {
load( $( group[ index + 1 ] || group[ 0 ] ).attr('href') );
load( $( group[ index - 1 ] || group[ group.length - 1 ] ).attr('href') );
}
},

_afterLoad: function () {
F.hideLoading();

Expand Down Expand Up @@ -702,6 +717,7 @@
F.wrap.hide().removeClass('fancybox-tmp');

F.bindEvents();
F._preload();

F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
},
Expand Down

0 comments on commit e7d1e16

Please sign in to comment.