Skip to content

Commit 438d3c4

Browse files
committed
Add lazyDistance option to prefetch 1 prev/next slide by default
1 parent 9aa67fe commit 438d3c4

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,
@@ -1348,6 +1349,25 @@
13481349
var slide = destiny.find(SLIDE_ACTIVE_SEL);
13491350
if( slide.length ) {
13501351
destiny = $(slide);
1352+
1353+
if( destiny.length == 1 && destiny.filter(SLIDE_SEL).length ) {
1354+
// Handling a single slide.
1355+
if( options.lazyDistance ) {
1356+
var prev = destiny.prevAll(':lt('+options.lazyDistance+')');
1357+
var next = destiny.nextAll(':lt('+options.lazyDistance+')');
1358+
1359+
// Add first/last sibling when there's no next/prev.
1360+
// (does not use options.lazyDistance currently).
1361+
if (options.loopHorizontal ) {
1362+
if(!next.length) {
1363+
next = destiny.siblings(':first');
1364+
} else if(!prev.length) {
1365+
prev = destiny.siblings(':last');
1366+
}
1367+
}
1368+
destiny = destiny.add(prev).add(next);
1369+
}
1370+
13511371
}
13521372
destiny.find('img[data-src], video[data-src], audio[data-src]').each(function(){
13531373
$(this).attr('src', $(this).data('src'));

0 commit comments

Comments
 (0)