Skip to content

Commit

Permalink
Add prop onAlign
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Apr 5, 2016
1 parent 88d5be8 commit 1abed98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ ReactDOM.render(<Trigger align={{
<td></td>
<td>builtin placement align map. used by placement prop</td>
</tr>
<tr>
<td>onAlign</td>
<td>function(popupDomNode, align)</td>
<td></td>
<td>callback when popup node is aligned</td>
</tr>
</tbody>
</table>

Expand Down
4 changes: 4 additions & 0 deletions src/Popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Popup = React.createClass({
className: PropTypes.string,
prefixCls: PropTypes.string,
onMouseLeave: PropTypes.func,
onAlign: PropTypes.func,
},

componentDidMount() {
Expand All @@ -31,6 +32,9 @@ const Popup = React.createClass({
this.currentAlignClassName = currentAlignClassName;
popupDomNode.className = this.getClassName(currentAlignClassName);
}
if (typeof props.onAlign === 'function') {
props.onAlign(popupDomNode, align);
}
},

getPopupDomNode() {
Expand Down
3 changes: 3 additions & 0 deletions src/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const Trigger = React.createClass({
popupVisible: PropTypes.bool,
maskTransitionName: PropTypes.string,
maskAnimation: PropTypes.string,
onAlign: PropTypes.func,
},

getDefaultProps() {
Expand All @@ -63,6 +64,7 @@ const Trigger = React.createClass({
action: [],
showAction: [],
hideAction: [],
onAlign: noop,
};
},

Expand Down Expand Up @@ -271,6 +273,7 @@ const Trigger = React.createClass({
transitionName={props.popupTransitionName}
maskAnimation={props.maskAnimation}
maskTransitionName={props.maskTransitionName}
onAlign={props.onAlign}
>
{props.popup}
</Popup>);
Expand Down

0 comments on commit 1abed98

Please sign in to comment.