Skip to content

Commit

Permalink
fix auto adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Oct 26, 2015
1 parent a303bff commit 2a3e923
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rc-tooltip",
"version": "3.0.2",
"version": "3.0.3",
"description": "tooltip ui component for react",
"keywords": [
"react",
Expand Down
24 changes: 14 additions & 10 deletions src/Popup.jsx
Expand Up @@ -11,9 +11,16 @@ const Popup = React.createClass({
wrap: PropTypes.object,
style: PropTypes.object,
onMouseEnter: PropTypes.func,
className: PropTypes.string,
onMouseLeave: PropTypes.func,
},

getDefaultProps() {
return {
className: '',
};
},

componentDidMount() {
this.rootNode = this.getPopupDomNode();
},
Expand All @@ -27,15 +34,15 @@ const Popup = React.createClass({
const props = this.props;
const {placement, prefixCls} = props;
if (placement) {
const originalClassName = getToolTipClassByPlacement(prefixCls, placement);
let nextClassName;
const originalClassName = popupDomNode.className;
let nextClassName = props.className + ' ';
if (placement.points) {
nextClassName = getToolTipClassByPlacement(prefixCls, align);
nextClassName += getToolTipClassByPlacement(prefixCls, align);
} else if (typeof placement === 'string') {
nextClassName = getToolTipClassByPlacement(prefixCls, fromPointsToPlacement(align));
nextClassName += getToolTipClassByPlacement(prefixCls, fromPointsToPlacement(align));
}
if (nextClassName !== originalClassName) {
popupDomNode.className = popupDomNode.className.replace(originalClassName, nextClassName);
popupDomNode.className = nextClassName;
}
}
},
Expand All @@ -60,13 +67,10 @@ const Popup = React.createClass({
render() {
const props = this.props;
const {prefixCls, placement, style} = props;
let className;
let className = props.className + ' ';

if (props.visible || !this.rootNode) {
className = getToolTipClassByPlacement(prefixCls, props.placement);
if (props.className) {
className += ' ' + props.className;
}
className += getToolTipClassByPlacement(prefixCls, props.placement);
} else {
// fix auto adjust
className = this.rootNode.className;
Expand Down

0 comments on commit 2a3e923

Please sign in to comment.