Refactor so that chevron and menu can be positioned independantly
This commit is contained in:
parent
0660b9feff
commit
6e7e091117
3 changed files with 17 additions and 8 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
|
||||
'use strict';
|
||||
|
||||
var classNames = require('classnames');
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
|
@ -51,25 +52,31 @@ module.exports = {
|
|||
};
|
||||
|
||||
var position = {
|
||||
top: props.top - 20,
|
||||
top: props.top,
|
||||
};
|
||||
|
||||
var chevron = null;
|
||||
if (props.left) {
|
||||
chevron = <div className="mx_ContextualMenu_chevron_left"></div>
|
||||
position.left = props.left + 8;
|
||||
chevron = <div style={ {top: props.chevronOffset} } className="mx_ContextualMenu_chevron_left"></div>
|
||||
position.left = props.left;
|
||||
} else {
|
||||
chevron = <div className="mx_ContextualMenu_chevron_right"></div>
|
||||
position.right = props.right + 8;
|
||||
position.right = props.right;
|
||||
}
|
||||
|
||||
var className = 'mx_ContextualMenu_wrapper';
|
||||
|
||||
var menuClasses = classNames({
|
||||
'mx_ContextualMenu': true,
|
||||
'mx_ContextualMenu_left': props.left,
|
||||
'mx_ContextualMenu_right': !props.left,
|
||||
});
|
||||
|
||||
// FIXME: If a menu uses getDefaultProps it clobbers the onFinished
|
||||
// property set here so you can't close the menu from a button click!
|
||||
var menu = (
|
||||
<div className={className}>
|
||||
<div className="mx_ContextualMenu" style={position}>
|
||||
<div className={className} style={position}>
|
||||
<div className={menuClasses}>
|
||||
{chevron}
|
||||
<Element {...props} onFinished={closeMenu}/>
|
||||
</div>
|
||||
|
|
|
@ -254,9 +254,10 @@ module.exports = React.createClass({
|
|||
|
||||
// The window X and Y offsets are to adjust position when zoomed in to page
|
||||
var x = buttonRect.right + window.pageXOffset;
|
||||
var y = buttonRect.top + (e.target.height / 2) + window.pageYOffset;
|
||||
var y = (buttonRect.top + (e.target.height / 2) + window.pageYOffset) - 19;
|
||||
var self = this;
|
||||
ContextualMenu.createMenu(MessageContextMenu, {
|
||||
chevronOffset: 10,
|
||||
mxEvent: this.props.mxEvent,
|
||||
left: x,
|
||||
top: y,
|
||||
|
|
|
@ -84,9 +84,10 @@ module.exports = React.createClass({
|
|||
var elementRect = e.target.getBoundingClientRect();
|
||||
// The window X and Y offsets are to adjust position when zoomed in to page
|
||||
var x = elementRect.right + window.pageXOffset;
|
||||
var y = elementRect.top + (elementRect.height / 2) + window.pageYOffset;
|
||||
var y = (elementRect.top + (elementRect.height / 2) + window.pageYOffset) - 43;
|
||||
var self = this;
|
||||
ContextualMenu.createMenu(Menu, {
|
||||
chevronOffset: 35,
|
||||
left: x,
|
||||
top: y,
|
||||
room: this.props.room,
|
||||
|
|
Loading…
Reference in a new issue