From 970aa4f84634c5ab4fe9a7c4c83dc9f2d8e3f912 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Aug 2015 13:17:17 +0800 Subject: [PATCH 1/4] Update code style --- components/alert/index.jsx | 17 +++++++---------- package.json | 2 +- style/components/alert.less | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/alert/index.jsx b/components/alert/index.jsx index 478dda5f7..525b12756 100644 --- a/components/alert/index.jsx +++ b/components/alert/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import { animationEndEvent, addEventListenerOnce } from '../util/index'; import Animate from 'rc-animate'; export default React.createClass({ @@ -16,10 +15,9 @@ export default React.createClass({ }, handleClose(e) { let dom = React.findDOMNode(this); - dom.style.height = dom.offsetHeight + 'px'; // Magic code - // 重复是去除浏览器渲染bug; + // 重复一次后才能正确设置 height dom.style.height = dom.offsetHeight + 'px'; this.setState({ @@ -29,7 +27,7 @@ export default React.createClass({ this.props.onClose.call(this, e); } }, - animationEnd(){ + animationEnd() { this.setState({ closed: true, closing: true @@ -58,8 +56,7 @@ export default React.createClass({ if (this.props.description) { let close = this.props.closable ? - + : ''; html =
@@ -82,16 +79,16 @@ export default React.createClass({ html =
{this.props.message} - {close} + {close}
; } } - return !this.state.closed ? - {html} - : null; + {html} + ; } }); diff --git a/package.json b/package.json index 73c6f598a..2e949b453 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "rc-util": "~2.0.3", "react-slick2": "~0.6.6", "reqwest": "~2.0.1", - "rc-animate": "^1.1.0" + "rc-animate": "~1.1.0" }, "devDependencies": { "autoprefixer-loader": "~2.0.0", diff --git a/style/components/alert.less b/style/components/alert.less index 14de15ff4..118cfefa7 100644 --- a/style/components/alert.less +++ b/style/components/alert.less @@ -153,7 +153,7 @@ } } - &-close{ + &-close { height: 0 !important; opacity: 0 !important; margin: 0; From 75fca7931365e0b394aed2e2f3577391dc558a18 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Aug 2015 13:43:57 +0800 Subject: [PATCH 2/4] remove magic code, use getBoundingClientRect replace offsetWidth --- components/tag/index.jsx | 20 +++++++++++--------- nico.js | 3 +-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/tag/index.jsx b/components/tag/index.jsx index b4f21cafd..c037f637a 100644 --- a/components/tag/index.jsx +++ b/components/tag/index.jsx @@ -14,10 +14,6 @@ class AntTag extends React.Component { close(e) { let dom = React.findDOMNode(this); - dom.style.width = dom.offsetWidth + 'px'; - // Magic code - // 重复是去除浏览器渲染bug; - dom.style.width = dom.offsetWidth + 'px'; this.setState({ closing: true }); @@ -30,6 +26,11 @@ class AntTag extends React.Component { this.props.onClose.call(this, e); } + componentDidMount() { + let dom = React.findDOMNode(this); + dom.style.width = (dom.getBoundingClientRect().width || dom.offsetWidth) + 'px'; + } + render() { let close = this.props.closable ? : ''; @@ -38,17 +39,18 @@ class AntTag extends React.Component { let className = this.props.prefixCls + ' ' + colorClass; className = this.state.closing ? className + ' ' + this.props.prefixCls + '-close' : className; - return (this.state.closed && !this.state.closing) ? null :
- - {close} -
; + return (this.state.closed && !this.state.closing) ? null + :
+ + {close} +
; } } AntTag.defaultProps = { prefixCls: prefixCls, closable: false, - onClose: function () {} + onClose: function() {} }; export default AntTag; diff --git a/nico.js b/nico.js index c78510568..10845fe98 100644 --- a/nico.js +++ b/nico.js @@ -90,8 +90,7 @@ exports.middlewares = [ watchOptions: { aggregateTimeout: 300, poll: true - }, - quiet: true + } }); try { return handler(req, res, next); From 9b28e46d4c3187e442d57293fdb271cedc2f85e2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Aug 2015 13:56:08 +0800 Subject: [PATCH 3/4] still use Magic offsetWidth set --- components/tag/index.jsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/tag/index.jsx b/components/tag/index.jsx index c037f637a..70972fcb2 100644 --- a/components/tag/index.jsx +++ b/components/tag/index.jsx @@ -14,6 +14,9 @@ class AntTag extends React.Component { close(e) { let dom = React.findDOMNode(this); + dom.style.width = dom.offsetWidth + 'px'; + // It's Magic Code, don't know why + dom.style.width = dom.offsetWidth + 'px'; this.setState({ closing: true }); @@ -26,11 +29,6 @@ class AntTag extends React.Component { this.props.onClose.call(this, e); } - componentDidMount() { - let dom = React.findDOMNode(this); - dom.style.width = (dom.getBoundingClientRect().width || dom.offsetWidth) + 'px'; - } - render() { let close = this.props.closable ? : ''; From 71b3f93d1fdc4d8988e92d7d6a4820032c73368e Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Aug 2015 13:58:05 +0800 Subject: [PATCH 4/4] update webpack middleware config --- nico.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nico.js b/nico.js index 10845fe98..e4881bc9a 100644 --- a/nico.js +++ b/nico.js @@ -90,7 +90,8 @@ exports.middlewares = [ watchOptions: { aggregateTimeout: 300, poll: true - } + }, + noInfo: true }); try { return handler(req, res, next);