diff --git a/examples/LazyLoad.js b/examples/LazyLoad.js index d5ecfeb74..c124cc92d 100644 --- a/examples/LazyLoad.js +++ b/examples/LazyLoad.js @@ -6,7 +6,8 @@ export default class LazyLoad extends Component { render() { const settings = { dots: true, - lazyLoad: true, + lazyLoad: 'ondemand', + ondemandSlidesToLoad: 2, infinite: true, speed: 500, slidesToShow: 1, diff --git a/src/default-props.js b/src/default-props.js index c98806a31..4f1559e28 100644 --- a/src/default-props.js +++ b/src/default-props.js @@ -24,6 +24,7 @@ let defaultProps = { infinite: true, initialSlide: 0, lazyLoad: null, + ondemandSlidesToLoad: 0, nextArrow: null, onEdge: null, onInit: null, diff --git a/src/utils/innerSliderUtils.js b/src/utils/innerSliderUtils.js index c06029d0a..f6972c33f 100644 --- a/src/utils/innerSliderUtils.js +++ b/src/utils/innerSliderUtils.js @@ -15,6 +15,9 @@ export const getOnDemandLazySlides = spec => { let onDemandSlides = []; let startIndex = lazyStartIndex(spec); let endIndex = lazyEndIndex(spec); + if(!isNaN(spec.ondemandSlidesToLoad) && spec.ondemandSlidesToLoad > 0 && spec.ondemandSlidesToLoad < spec.slideCount){ + endIndex = endIndex + spec.ondemandSlidesToLoad; + } for (let slideIndex = startIndex; slideIndex < endIndex; slideIndex++) { if (spec.lazyLoadedList.indexOf(slideIndex) < 0) { onDemandSlides.push(slideIndex);