Skip to content

Commit

Permalink
Add lazyDistance option to prefetch 1 prev/next slide by default
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jun 29, 2015
1 parent 4ca2fa4 commit 5de9b4c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions jquery.fullPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
slidesNavigation: false,
slidesNavPosition: 'bottom',
scrollBar: false,
lazyDistance: 1,

//scrolling
css3: true,
Expand Down Expand Up @@ -1345,6 +1346,25 @@
var slide = destiny.find(SLIDE_ACTIVE_SEL);
if( slide.length ) {
destiny = $(slide);

if( destiny.length == 1 && destiny.filter(SLIDE_SEL).length ) {
// Handling a single slide.
if( options.lazyDistance ) {
var prev = destiny.prevAll(':lt('+options.lazyDistance+')');
var next = destiny.nextAll(':lt('+options.lazyDistance+')');

// Add first/last sibling when there's no next/prev.
// (does not use options.lazyDistance currently).
if (options.loopHorizontal ) {
if(!next.length) {
next = destiny.siblings(':first');
} else if(!prev.length) {
prev = destiny.siblings(':last');
}
}
destiny = destiny.add(prev).add(next);
}

}
destiny.find('img[data-src], video[data-src], audio[data-src]').each(function(){
$(this).attr('src', $(this).data('src'));
Expand Down

0 comments on commit 5de9b4c

Please sign in to comment.