Fix dimension spacing depending on scale
This commit is contained in:
parent
063467fb58
commit
910aa4479b
5 changed files with 12 additions and 6 deletions
|
@ -59,7 +59,7 @@ export function Container(props: IContainerProps): JSX.Element {
|
||||||
</rect>);
|
</rect>);
|
||||||
// Dimension props
|
// Dimension props
|
||||||
const depth = GetDepth(props.model);
|
const depth = GetDepth(props.model);
|
||||||
const dimensionMargin = DIMENSION_MARGIN * depth;
|
const dimensionMargin = DIMENSION_MARGIN * depth / props.scale;
|
||||||
const id = `dim-${props.model.properties.id}`;
|
const id = `dim-${props.model.properties.id}`;
|
||||||
const xStart: number = 0;
|
const xStart: number = 0;
|
||||||
const xEnd = width;
|
const xEnd = width;
|
||||||
|
|
|
@ -70,7 +70,7 @@ function AddNewDimension(currentDepth: number, min: number, max: number, lastY:
|
||||||
const id = `dim-depth-${currentDepth}`;
|
const id = `dim-depth-${currentDepth}`;
|
||||||
const xStart = min;
|
const xStart = min;
|
||||||
const xEnd = max;
|
const xEnd = max;
|
||||||
const y = lastY + (DIMENSION_MARGIN * (currentDepth + 1));
|
const y = (lastY + (DIMENSION_MARGIN * (currentDepth + 1))) / scale;
|
||||||
const strokeWidth = 1;
|
const strokeWidth = 1;
|
||||||
const width = xEnd - xStart;
|
const width = xEnd - xStart;
|
||||||
const text = width
|
const text = width
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { DIMENSION_MARGIN } from '../../../utils/default';
|
||||||
|
|
||||||
interface ISymbolProps {
|
interface ISymbolProps {
|
||||||
model: ISymbolModel
|
model: ISymbolModel
|
||||||
|
scale: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Symbol(props: ISymbolProps): JSX.Element {
|
export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
|
@ -15,7 +16,7 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
x={props.model.x}
|
x={props.model.x}
|
||||||
y={-DIMENSION_MARGIN}
|
y={-DIMENSION_MARGIN / props.scale}
|
||||||
>
|
>
|
||||||
<Interweave
|
<Interweave
|
||||||
noWrap={true}
|
noWrap={true}
|
||||||
|
@ -30,7 +31,7 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
<image
|
<image
|
||||||
href={href}
|
href={href}
|
||||||
x={props.model.x}
|
x={props.model.x}
|
||||||
y={-DIMENSION_MARGIN}
|
y={-DIMENSION_MARGIN / props.scale}
|
||||||
height={props.model.height}
|
height={props.model.height}
|
||||||
width={props.model.width} />
|
width={props.model.width} />
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,13 +4,18 @@ import { Symbol } from './Symbol';
|
||||||
|
|
||||||
interface ISymbolLayerProps {
|
interface ISymbolLayerProps {
|
||||||
symbols: Map<string, ISymbolModel>
|
symbols: Map<string, ISymbolModel>
|
||||||
|
scale: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SymbolLayer(props: ISymbolLayerProps): JSX.Element {
|
export function SymbolLayer(props: ISymbolLayerProps): JSX.Element {
|
||||||
const symbols: JSX.Element[] = [];
|
const symbols: JSX.Element[] = [];
|
||||||
props.symbols.forEach((symbol) => {
|
props.symbols.forEach((symbol) => {
|
||||||
symbols.push(
|
symbols.push(
|
||||||
<Symbol key={`symbol-${symbol.id}`} model={symbol} />
|
<Symbol
|
||||||
|
key={`symbol-${symbol.id}`}
|
||||||
|
model={symbol}
|
||||||
|
scale={props.scale}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -132,7 +132,7 @@ export function SVG(props: ISVGProps): JSX.Element {
|
||||||
{SHOW_DIMENSIONS_PER_DEPTH
|
{SHOW_DIMENSIONS_PER_DEPTH
|
||||||
? <DepthDimensionLayer scale={scale} roots={props.children} />
|
? <DepthDimensionLayer scale={scale} roots={props.children} />
|
||||||
: null}
|
: null}
|
||||||
<SymbolLayer symbols={props.symbols} />
|
<SymbolLayer scale={scale} symbols={props.symbols} />
|
||||||
<Selector scale={scale} selected={props.selected} /> {/* leave this at the end so it can be removed during the svg export */}
|
<Selector scale={scale} selected={props.selected} /> {/* leave this at the end so it can be removed during the svg export */}
|
||||||
</svg>
|
</svg>
|
||||||
</ReactSVGPanZoom>
|
</ReactSVGPanZoom>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue