Skip to content

Commit

Permalink
fix carousel dots bug when dots={false}
Browse files Browse the repository at this point in the history
  • Loading branch information
观通 committed Sep 27, 2016
1 parent a1da195 commit 039d034
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
1 change: 0 additions & 1 deletion components/carousel/demo/carousel.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const App = React.createClass({
dots: true,
autoplay: true,
infinite: true,
mode: 'banner',
selectedIndex: this.state.current,
beforeChange: this.beforeSlide,
afterChange: this.slideTo,
Expand Down
69 changes: 36 additions & 33 deletions components/carousel/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,42 @@ export default class Carousel extends React.Component<CarouselProps, any> {
wrapCls = `${props.prefixCls} ${props.prefixCls}-vertical`;
}

const Decorators = [{
component: React.createClass({
render() {
const self = this;
const indexes = this.getIndexes(self.props.slideCount, self.props.slidesToScroll);
return (
<div className={`${prefixCls}-wrap`}>
{
indexes.map(function(index) {
const dotCls = classNames({
[`${prefixCls}-wrap-dot`]: true,
[`${prefixCls}-wrap-dot-active`]: index === current,
});
return (
<div className={dotCls} key={index}>
<span></span>
</div>
);
})
}
</div>
);
},
getIndexes(count, inc) {
const arr = [];
for (let i = 0; i < count; i += inc) {
arr.push(i);
}
return arr;
},
}),
position: 'BottomCenter',
}];
let Decorators = [];
if (props.dots) {
Decorators = [{
component: React.createClass({
render() {
const self = this;
const indexes = this.getIndexes(self.props.slideCount, self.props.slidesToScroll);
return (
<div className={`${prefixCls}-wrap`}>
{
indexes.map(function(index) {
const dotCls = classNames({
[`${prefixCls}-wrap-dot`]: true,
[`${prefixCls}-wrap-dot-active`]: index === current,
});
return (
<div className={dotCls} key={index}>
<span></span>
</div>
);
})
}
</div>
);
},
getIndexes(count, inc) {
const arr = [];
for (let i = 0; i < count; i += inc) {
arr.push(i);
}
return arr;
},
}),
position: 'BottomCenter',
}];
}

return (
<div className={wrapCls}>
Expand Down

0 comments on commit 039d034

Please sign in to comment.