Skip to content

Commit 5de9b4c

Browse files
committed
Add lazyDistance option to prefetch 1 prev/next slide by default
1 parent 4ca2fa4 commit 5de9b4c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

jquery.fullPage.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
slidesNavigation: false,
104104
slidesNavPosition: 'bottom',
105105
scrollBar: false,
106+
lazyDistance: 1,
106107

107108
//scrolling
108109
css3: true,
@@ -1345,6 +1346,25 @@
13451346
var slide = destiny.find(SLIDE_ACTIVE_SEL);
13461347
if( slide.length ) {
13471348
destiny = $(slide);
1349+
1350+
if( destiny.length == 1 && destiny.filter(SLIDE_SEL).length ) {
1351+
// Handling a single slide.
1352+
if( options.lazyDistance ) {
1353+
var prev = destiny.prevAll(':lt('+options.lazyDistance+')');
1354+
var next = destiny.nextAll(':lt('+options.lazyDistance+')');
1355+
1356+
// Add first/last sibling when there's no next/prev.
1357+
// (does not use options.lazyDistance currently).
1358+
if (options.loopHorizontal ) {
1359+
if(!next.length) {
1360+
next = destiny.siblings(':first');
1361+
} else if(!prev.length) {
1362+
prev = destiny.siblings(':last');
1363+
}
1364+
}
1365+
destiny = destiny.add(prev).add(next);
1366+
}
1367+
13481368
}
13491369
destiny.find('img[data-src], video[data-src], audio[data-src]').each(function(){
13501370
$(this).attr('src', $(this).data('src'));

0 commit comments

Comments
 (0)