Skip to content

Commit

Permalink
Add onClick prop to floating panel
Browse files Browse the repository at this point in the history
If panels are stored in array and have fix key, simply splice and push the clicked panel to bring it to front,
the newly pushed panel will have highest z-order.
  • Loading branch information
yapcheahshen committed May 10, 2015
1 parent b5be340 commit 6e34dc6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/jsx/panel.js
Expand Up @@ -2,7 +2,14 @@
var FloatingPanel = React.createClass({
displayName: 'FloatingPanel',
mixins: [Mixins.PanelWrapper],

propTypes: {
left:React.PropTypes.number,
top:React.PropTypes.number,
width:React.PropTypes.number,
style:React.PropTypes.object,
onClick:React.PropTypes.func,
},

getDefaultProps: function () {
return {
"left": 0,
Expand Down Expand Up @@ -61,6 +68,12 @@ var FloatingPanel = React.createClass({
this.setState({ left: left, top: top });
}
},

handleMouseClick: function (e) {
if (typeof this.props.onClick === "function") {
this.props.onClick(e);
}
},

render: function() {
var transform = "translate3d(" + Utils.pixelsOf(this.state.left) + ", " + Utils.pixelsOf(this.state.top) + ", 0)",
Expand Down Expand Up @@ -94,7 +107,7 @@ var FloatingPanel = React.createClass({
this.skipUpdate = false;
}

return React.createElement("div", {style:wrapperStyle}, this.inner);
return React.createElement("div", {style:wrapperStyle, onClick:this.handleMouseClick}, this.inner);
}

});
Expand Down

0 comments on commit 6e34dc6

Please sign in to comment.