Browse Source

Add Lazy Load Functionality

Just added lazy load functionality
pull/382/head
Andrius Solopovas 8 years ago committed by GitHub
parent
commit
94decefe6c
  1. 18
      responsiveslides.js

18
responsiveslides.js

@ -27,6 +27,7 @@
"navContainer": "", // Selector: Where auto generated controls should be appended to, default is after the <ul> "navContainer": "", // Selector: Where auto generated controls should be appended to, default is after the <ul>
"manualControls": "", // Selector: Declare custom pager navigation "manualControls": "", // Selector: Declare custom pager navigation
"namespace": "rslides", // String: change the default namespace used "namespace": "rslides", // String: change the default namespace used
"lazy": false // Boolean: Lazy Load Mode
"before": $.noop, // Function: Before callback "before": $.noop, // Function: Before callback
"after": $.noop // Function: After callback "after": $.noop // Function: After callback
}, options); }, options);
@ -92,8 +93,7 @@
})(), })(),
// Fading animation // Fading animation
slideTo = function (idx) { slideToHelper = function(idx) {
settings.before(idx);
// If CSS3 transitions are supported // If CSS3 transitions are supported
if (supportsTransitions) { if (supportsTransitions) {
$slide $slide
@ -125,6 +125,20 @@
index = idx; index = idx;
}); });
} }
}
slideTo = function (idx) {
settings.before(idx);
if (settings.lazy) {
var imgSlide = $($($slide).find('img')[idx]);
var dataSrc = imgSlide.data('src');
imgSlide.attr('src', dataSrc);
imgSlide.on('load', function() {
slideToHelper(idx);
})
} else {
slideToHelper(idx);
}
}; };
// Random order // Random order

Loading…
Cancel
Save