From b5bd74b0edb528920afd21a493913d8a93ec0ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A1=BA=E5=A0=82?= Date: Tue, 30 Oct 2018 20:53:12 +0800 Subject: [PATCH] =?UTF-8?q?Album.show=E6=B7=BB=E5=8A=A0onChange=E3=80=81on?= =?UTF-8?q?Close=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - demo/AlbumDemo.jsx | 6 +++--- src/Album.jsx | 4 ++-- src/Carousel.jsx | 1 + src/Photo.jsx | 1 - src/Viewer.jsx | 4 ++++ 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d56d39e..35583fe 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,6 @@ Yes please! See the [CONTRIBUTING](https://github.com/uxcore/uxcore/blob/master/ With this method, the component can be used by calling `Album.show({src: 'foo/url'})` or `Album.show({photos: [, ]})` directly. - #### config | Name | Type | Required | Default | Comments | diff --git a/demo/AlbumDemo.jsx b/demo/AlbumDemo.jsx index 1cb46bc..47996c3 100644 --- a/demo/AlbumDemo.jsx +++ b/demo/AlbumDemo.jsx @@ -81,9 +81,9 @@ export default class Demo extends React.Component { thumbPlacement="right" thumbBackground="#000" ref={(album) => { this.album = album; }} - // onChange={(index) => { console.log('onChange', index); }} - // onOpen={(index) => { console.log('onOpen', index); }} - // onClose={() => { console.log('onClose'); }} + onChange={(index) => { console.log('onChange', index); }} + onOpen={(index) => { console.log('onOpen', index); }} + onClose={() => { console.log('onClose'); }} > { if (typeof config.onChange === 'function') { config.onChange(index); } - } + }; /** * 关闭 @@ -369,7 +369,7 @@ Album.show = (option = {}) => { if (typeof config.onClose === 'function') { config.onClose(); } - } + }; const prefixCls = option.prefixCls || 'kuma-uxcore-album'; diff --git a/src/Carousel.jsx b/src/Carousel.jsx index e71f755..c73d0dd 100644 --- a/src/Carousel.jsx +++ b/src/Carousel.jsx @@ -19,6 +19,7 @@ class Carousel extends React.Component { inView: false, } + static propTypes = { children: PropTypes.any, current: PropTypes.number, diff --git a/src/Photo.jsx b/src/Photo.jsx index f4c76fb..0fb2c1c 100644 --- a/src/Photo.jsx +++ b/src/Photo.jsx @@ -27,7 +27,6 @@ Photo.defaultProps = { src: '', }; - // http://facebook.github.io/react/docs/reusable-components.html Photo.propTypes = { src: PropTypes.string, diff --git a/src/Viewer.jsx b/src/Viewer.jsx index 44cc9aa..4590b55 100644 --- a/src/Viewer.jsx +++ b/src/Viewer.jsx @@ -116,6 +116,10 @@ class Viewer extends React.Component { }, this.handleChange.bind(this)); } + /** + * 变化时 + * @param {Number} index + */ handleChange(index) { const { onChange } = this.props; let { current } = this.state;