Skip to content

Commit d6d5e92

Browse files
committed
responsive lazyloading bug fixed
fixes: #850
1 parent ec4042f commit d6d5e92

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/mixins/helpers.js

+16
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ var helpers = {
8080
} else {
8181
this.autoPlay(props.autoplay);
8282
}
83+
84+
const lazyLoadedList = this.state.lazyLoadedList
85+
let startIndex, endIndex
86+
if (props.centerMode) {
87+
startIndex = this.state.currentSlide - props.slidesToShow / 2
88+
endIndex = this.state.currentSlide + props.slidesToShow / 2
89+
} else {
90+
startIndex = this.state.currentSlide
91+
endIndex = this.state.currentSlide + props.slidesToShow
92+
}
93+
for (let slideIndex = startIndex; slideIndex < endIndex; slideIndex += 1) {
94+
if (lazyLoadedList.indexOf(slideIndex) < 0) {
95+
lazyLoadedList.push(slideIndex)
96+
}
97+
}
8398

8499
this.setState({
85100
slideCount,
@@ -88,6 +103,7 @@ var helpers = {
88103
trackWidth,
89104
slideHeight,
90105
listHeight,
106+
lazyLoadedList
91107
}, function () {
92108

93109
var targetLeft = getTrackLeft(assign({

0 commit comments

Comments
 (0)