From c53376c37ff44b6637afaf1f8f3f9bcfd7213869 Mon Sep 17 00:00:00 2001 From: Caldis <532607446@qq.com> Date: Mon, 2 Sep 2019 21:01:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Zmage.js | 15 ++++++--------- src/components/Browser/Browser.js | 12 ++++++------ src/config/default.js | 2 ++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Zmage.js b/src/Zmage.js index 6a99263..d72d288 100644 --- a/src/Zmage.js +++ b/src/Zmage.js @@ -18,31 +18,28 @@ export default class ReactZmage extends React.PureComponent { super(props) this.coverRef = React.createRef() - this.isControlled = this.props.hasOwnProperty('browsing') + this.isBrowsingControlled = this.props.hasOwnProperty('browsing') this.state = { // 浏览 browsing: false, } - // TODO:FEATURE 懒加载 - // TODO:FEATURE 翻页动画 // TODO:FEATURE 移动端的拖拽翻页 - // TODO:ENHANCE 禁用移动端的滑动退出及禁用滚动 - // TODO:ENHANCE 移动端下点击隐藏的背景按下时会变暗 + // TODO:ENHANCE 禁用移动端的滑动退出 // TODO:BUG 移动端下左右按钮 } /* 切换查看状态 */ inBrowsing = () => { - if (this.isControlled) { + if (this.isBrowsingControlled) { this.props.onBrowsing(true) } else { this.setState({ browsing: true }) } } outBrowsing = () => { - if (this.isControlled) { + if (this.isBrowsingControlled) { this.props.onBrowsing(false) } else { this.setState({ browsing: false }) @@ -93,8 +90,8 @@ export default class ReactZmage extends React.PureComponent { {/*查看叠层*/} { - const { isControlled, coverRef, set, onBrowsing } = this.props + const { isBrowsingControlled, coverRef, set, onBrowsing } = this.props const { show, page, pageIsCover } = this.state if (!show) { window.addEventListener('keydown', this.handleKeyDown) @@ -82,13 +81,13 @@ export default class Browser extends React.PureComponent { window.requestAnimationFrame(() => { this.setState({ show:true, zoom:false, rotate:0, }, () => { pageIsCover && hideCover(coverRef, set, page) - !isControlled && typeof onBrowsing === "function" && onBrowsing(true) + !isBrowsingControlled && typeof onBrowsing === "function" && onBrowsing(true) }) }) } } unInit = ({ force }={}) => { - const { isControlled, coverRef, set, onBrowsing } = this.props + const { isBrowsingControlled, coverRef, set, onBrowsing } = this.props const { show, page, pageIsCover } = this.state if (show || force) { window.removeEventListener('keydown', this.handleKeyDown) @@ -97,7 +96,7 @@ export default class Browser extends React.PureComponent { this.setState({ show:false, zoom:false, rotate:0 }, () => setTimeout(() => { this.setState({ mount:false }, () => { pageIsCover && showCover(coverRef, set, page) - !isControlled && typeof onBrowsing === "function" && onBrowsing(false) + !isBrowsingControlled && typeof onBrowsing === "function" && onBrowsing(false) }) }, animationDuration)) } @@ -108,6 +107,7 @@ export default class Browser extends React.PureComponent { * 事件处理 **/ handleKeyDown = (e) => { + console.log('handleKeyDown') const { preset, set, hotKey:userHotKey, loop, outBrowsing } = this.props const { zoom, page } = this.state // 合并熱鍵設定 @@ -284,7 +284,7 @@ Browser.contextType = Context Browser.defaultProps = { // Controlled status - isControlled: false, + isBrowsingControlled: false, browsing: false, // Internal coverRef: React.createRef(), diff --git a/src/config/default.js b/src/config/default.js index 59120f2..cb8fcec 100644 --- a/src/config/default.js +++ b/src/config/default.js @@ -86,7 +86,9 @@ export const defType = { ]), // 动画 animate: PropTypes.shape({ + // 缩放动画 (未实现) browsing: PropTypes.bool, + // 翻页动画 flip: PropTypes.oneOf([ // 渐变 (set小於3時强制使用) "fade",