@ustutt/grapheditor-webcomponent
Advanced tools
Comparing version 0.7.0-pre1 to 0.7.0
@@ -87,2 +87,9 @@ import { Selection } from 'd3-selection'; | ||
/** | ||
* Get the current stroke width of a path. | ||
* | ||
* @param singlePathSelection the selection containing the path to measure the stroke width of | ||
* @returns the parsed strokeWidth or 1 if parsing failed | ||
*/ | ||
protected parseStrokeWidth(singlePathSelection: Selection<SVGPathElement, unknown, any, unknown>): number; | ||
/** | ||
* Calculate a normal vector pointing in the direction of the path at the positonOnLine. | ||
@@ -89,0 +96,0 @@ * |
@@ -355,2 +355,22 @@ /* | ||
/** | ||
* Get the current stroke width of a path. | ||
* | ||
* @param singlePathSelection the selection containing the path to measure the stroke width of | ||
* @returns the parsed strokeWidth or 1 if parsing failed | ||
*/ | ||
parseStrokeWidth(singlePathSelection) { | ||
var _a; | ||
const styleWidth = (_a = singlePathSelection.style('stroke-width')) !== null && _a !== void 0 ? _a : '1px'; | ||
if (styleWidth.includes('calc')) { | ||
// impossible to calculate actual stroke width | ||
return 1; | ||
} | ||
const strokeWidth = parseFloat(styleWidth.replace(/px/, '')); | ||
if (isNaN(strokeWidth)) { | ||
// stroke width could not be parsed | ||
return 1; | ||
} | ||
return strokeWidth; | ||
} | ||
/** | ||
* Calculate a normal vector pointing in the direction of the path at the positonOnLine. | ||
@@ -529,3 +549,3 @@ * | ||
const singleEdgeSelection = select(this).datum(edge); | ||
const strokeWidth = parseFloat(singleEdgeSelection.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = self.parseStrokeWidth(singleEdgeSelection); | ||
// eslint-disable-next-line complexity | ||
@@ -646,3 +666,3 @@ singleEdgeSelection.attr('d', (d) => { | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = this.parseStrokeWidth(path); | ||
const textSelection = edgeGroupSelection.selectAll('g.text-component') | ||
@@ -802,3 +822,3 @@ .data(d.texts != null ? d.texts : []); | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = self.parseStrokeWidth(path); | ||
const positionOnLine = normalizePositionOnLine(d.positionOnLine); | ||
@@ -822,3 +842,3 @@ const absolutePositionOnLine = self.calculateAbsolutePositionOnLine(length, positionOnLine, d.absolutePositionOnLine); | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = this.parseStrokeWidth(path); | ||
if (d.markerStart != null) { | ||
@@ -825,0 +845,0 @@ this.updateEndMarkerPosition(path, length, 0, d.markerStart, d.sourceHandle, 'marker-start', strokeWidth, edgeGroupSelection); |
@@ -87,2 +87,9 @@ import { Selection } from 'd3-selection'; | ||
/** | ||
* Get the current stroke width of a path. | ||
* | ||
* @param singlePathSelection the selection containing the path to measure the stroke width of | ||
* @returns the parsed strokeWidth or 1 if parsing failed | ||
*/ | ||
protected parseStrokeWidth(singlePathSelection: Selection<SVGPathElement, unknown, any, unknown>): number; | ||
/** | ||
* Calculate a normal vector pointing in the direction of the path at the positonOnLine. | ||
@@ -89,0 +96,0 @@ * |
@@ -358,2 +358,22 @@ "use strict"; | ||
/** | ||
* Get the current stroke width of a path. | ||
* | ||
* @param singlePathSelection the selection containing the path to measure the stroke width of | ||
* @returns the parsed strokeWidth or 1 if parsing failed | ||
*/ | ||
parseStrokeWidth(singlePathSelection) { | ||
var _a; | ||
const styleWidth = (_a = singlePathSelection.style('stroke-width')) !== null && _a !== void 0 ? _a : '1px'; | ||
if (styleWidth.includes('calc')) { | ||
// impossible to calculate actual stroke width | ||
return 1; | ||
} | ||
const strokeWidth = parseFloat(styleWidth.replace(/px/, '')); | ||
if (isNaN(strokeWidth)) { | ||
// stroke width could not be parsed | ||
return 1; | ||
} | ||
return strokeWidth; | ||
} | ||
/** | ||
* Calculate a normal vector pointing in the direction of the path at the positonOnLine. | ||
@@ -532,3 +552,3 @@ * | ||
const singleEdgeSelection = (0, d3_selection_1.select)(this).datum(edge); | ||
const strokeWidth = parseFloat(singleEdgeSelection.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = self.parseStrokeWidth(singleEdgeSelection); | ||
// eslint-disable-next-line complexity | ||
@@ -649,3 +669,3 @@ singleEdgeSelection.attr('d', (d) => { | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = this.parseStrokeWidth(path); | ||
const textSelection = edgeGroupSelection.selectAll('g.text-component') | ||
@@ -805,3 +825,3 @@ .data(d.texts != null ? d.texts : []); | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = self.parseStrokeWidth(path); | ||
const positionOnLine = (0, __1.normalizePositionOnLine)(d.positionOnLine); | ||
@@ -825,3 +845,3 @@ const absolutePositionOnLine = self.calculateAbsolutePositionOnLine(length, positionOnLine, d.absolutePositionOnLine); | ||
const length = path.node().getTotalLength(); | ||
const strokeWidth = parseFloat(path.style('stroke-width').replace(/px/, '')); | ||
const strokeWidth = this.parseStrokeWidth(path); | ||
if (d.markerStart != null) { | ||
@@ -828,0 +848,0 @@ this.updateEndMarkerPosition(path, length, 0, d.markerStart, d.sourceHandle, 'marker-start', strokeWidth, edgeGroupSelection); |
{ | ||
"name": "@ustutt/grapheditor-webcomponent", | ||
"version": "0.7.0-pre1", | ||
"version": "0.7.0", | ||
"description": "Webcomponent for displaying and editing graphs.", | ||
@@ -5,0 +5,0 @@ "author": "Fabian Bühler <fabian.buehler@iaas.uni-stuttgart.de>", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2667650
24885