Skip to content

Add new Component Swiper#306

Merged
cpylua merged 20 commits intomasterfrom
feature/swiper
Jun 8, 2017
Merged

Add new Component Swiper#306
cpylua merged 20 commits intomasterfrom
feature/swiper

Conversation

@ArvinTung
Copy link
Contributor

Fixes #232

add new component: Swiper

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.055% when pulling 829ecb4 on feature/swiper into 1cb18ca on master.

| dotsSize | 下方翻页按钮大小 | string | `'normal'` | `'small'`, `'large'` |
| arrows | 是否显示两侧翻页按钮 | bool | `false` | `true`, `false` |
| arrowsType | 两侧箭头颜色 | string | `'dark'` | `'dark'`, `'light'` |
| onChange | 切换时回调函数 | func(current, prev) | `noop` | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

className, prefix 加上去


import SwiperDots from './SwiperDots';

export default class Swiper extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(PureComponent || Component)

},
{
path: 'component/swiper',
title: 'Swiper 幻灯片',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

叫轮播吧

import React, { Component } from 'react';
import cx from 'classnames';

export default class SwiperDots extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(PureComponent || Component)

`${prefix}-swiper__dots-${dotsSize}`
);

const clonedItems = [].slice.call(items);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要单独建个数组吧,你直接遍历跳过0和length-1就行了吧。

这样做有些浪费。

arrowsType: 'dark'
};

static setStyle(target, styles) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种函数就不要写在类上了,写成模块私有的函数就可以了,调用不是更方便嘛。

this.setState({
currentIndex: length - 1
}),
300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个时间最好能配置

/>
</div>}
<div
ref={swiperContainer => (this.swiperContainer = swiperContainer)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数提出去,不要这么写


init = (isFirstTime = true) => {
this.setSwiperWidth();
this.setInnerElements();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么每次都要调用呢?

this.swiperWidth = this.swiper.getBoundingClientRect().width;
}

setInnerElements() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑删掉这个函数

const { autoplay } = this.props;
autoplay && this.startAutoplay();
this.init();
this.isFirstMounted = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑删掉这个变量

currentIndex={currentIndex}
onDotsClick={this.handleDotsClick}
/>}
<WindowResizeHandler onResize={this.init} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throttle一下

| 参数 | 说明 | 类型 | 默认值 | 备选值 |
| --------------- | ---------------------------- | ------------------- | --------------- | ------------------------------------ |
| autoplay | 是否自动切换 | bool | `false` | `false`, `true` |
| autoplayIterval | 自动切换间隔时间(ms) | number | `3000` | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interval

@@ -0,0 +1,138 @@
## Swiper 幻灯片
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字

Copy link
Contributor

@cpylua cpylua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改一下

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 93.03% when pulling 4723bfc on feature/swiper into 1cb18ca on master.

@ArvinTung
Copy link
Contributor Author

done

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 93.03% when pulling 2e89b62 on feature/swiper into 1cb18ca on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 92.998% when pulling 81e0879 on feature/swiper into 1cb18ca on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 93.159% when pulling 369c38f on feature/swiper into 1cb18ca on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 93.162% when pulling f04a23d on feature/swiper into 1cb18ca on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 93.173% when pulling bfb4649 on feature/swiper into 2c87880 on master.

@cpylua cpylua merged commit 2cd78b8 into master Jun 8, 2017
@cpylua cpylua deleted the feature/swiper branch June 8, 2017 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants