Skip to content

Commit f46206c

Browse files
committed
Prevent error to be thrown when targetLeft is not available
1 parent b67f98b commit f46206c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mixins/trackHelper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ export var getTrackLeft = function (spec) {
143143
targetSlide = ReactDOM.findDOMNode(spec.trackRef).children[(spec.slideIndex + spec.slidesToShow + 1)];
144144
}
145145

146-
targetLeft = targetSlide ? targetSlide.offsetLeft * -1 : 0;
147-
targetLeft += (spec.listWidth - targetSlide.offsetWidth) / 2;
146+
if (targetSlide) {
147+
targetLeft = targetSlide.offsetLeft * -1 + (spec.listWidth - targetSlide.offsetWidth) / 2;
148+
}
148149
}
149150
}
150151

0 commit comments

Comments
 (0)