mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Smaller node bounding boxes for onHover/onClick
foreignObject was huge on firefox.
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user