Smaller node bounding boxes for onHover/onClick

foreignObject was huge on firefox.
This commit is contained in:
Simon Howe
2016-08-04 16:49:38 +02:00
parent 1d3ad9e12b
commit bf8d8a89e7
2 changed files with 21 additions and 4 deletions

View File

@@ -105,10 +105,14 @@ class Node extends React.Component {
const useSvgLabels = exportingGraph;
const size = nodeScale(scaleFactor);
const networkOffset = focused ? nodeScale(scaleFactor * 0.67) : nodeScale(0.67);
const mouseEvents = {
onClick: this.handleMouseClick,
onMouseEnter: this.handleMouseEnter,
onMouseLeave: this.handleMouseLeave,
};
return (
<g className={nodeClassName} transform={transform}
onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
<g className={nodeClassName} transform={transform}>
{useSvgLabels ?
@@ -116,7 +120,7 @@ class Node extends React.Component {
<foreignObject x={labelOffsetX} y={labelOffsetY} width={labelWidth}
height="10em" transform={labelTransform}>
<div className="node-label-wrapper" onClick={this.handleMouseClick}>
<div className="node-label-wrapper" {...mouseEvents}>
<div className={labelClassName}>
<MatchedText text={label} match={matches.get('label')} />
</div>
@@ -127,7 +131,7 @@ class Node extends React.Component {
</div>
</foreignObject>}
<g onClick={this.handleMouseClick}>
<g {...mouseEvents}>
<NodeShapeType
size={size}
color={color}

View File

@@ -368,6 +368,19 @@ h2 {
}
.node-label-wrapper {
//
// inline-block so wrapper is only as wide as content.
//
display: inline-block;
//
// - inline-block gets a different baseline depending on overflow value
// - this element gets its overflow value changed sometimes.
// - explicitly set the baseline so the text doesn't jump up and down.
// http://stackoverflow.com/questions/9273016
//
vertical-align: top;
cursor: pointer;
}