Skip to content

Commit bb01404

Browse files
committed
Arrowhead Id with random string. In case of multiple timelines
1 parent 96eefd3 commit bb01404

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

arrow.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* Class to easily draw lines to connect items in the vis Timeline module.
66
*
7-
* @version 4.1.1
8-
* @date 2023-11-07
7+
* @version 4.3.1
8+
* @date 2024-01-16
99
*
1010
* @copyright (c) Javi Domenech (javdome@gmail.com)
1111
*
@@ -90,6 +90,9 @@ export default class Arrow {
9090
/** @private @type {SVGPathElement[]} */
9191
this._dependencyPath = [];
9292

93+
/** @private @type {string} */
94+
this._arrowHeadId = `arrowhead-${Math.random().toString(36).substring(2)}`;
95+
9396
this._initialize();
9497
}
9598

@@ -105,7 +108,7 @@ export default class Arrow {
105108
this._timeline.dom.center.appendChild(this._svg);
106109

107110
//Configure the arrowHead
108-
this._arrowHead.setAttribute("id", "arrowhead0");
111+
this._arrowHead.setAttribute("id", this._arrowHeadId);
109112
this._arrowHead.setAttribute("viewBox", "-10 -5 10 10");
110113
this._arrowHead.setAttribute("refX", "-7");
111114
this._arrowHead.setAttribute("refY", "0");
@@ -209,7 +212,7 @@ export default class Arrow {
209212

210213
if (this._followRelationships && item_2.mid_x < item_1.mid_x) {
211214
item_2.right += 10; // Space for the arrowhead.
212-
this._dependencyPath[index].setAttribute("marker-start", "url(#arrowhead0)");
215+
this._dependencyPath[index].setAttribute("marker-start", `url(#${this._arrowHeadId})`);
213216
this._dependencyPath[index].setAttribute("marker-end", "");
214217
this._dependencyPath[index].setAttribute(
215218
"d",
@@ -232,7 +235,7 @@ export default class Arrow {
232235
);
233236
} else {
234237
item_2.left -= 10; // Space for the arrowhead.
235-
this._dependencyPath[index].setAttribute("marker-end", "url(#arrowhead0)");
238+
this._dependencyPath[index].setAttribute("marker-end", `url(#${this._arrowHeadId})`);
236239
this._dependencyPath[index].setAttribute("marker-start", "");
237240
this._dependencyPath[index].setAttribute(
238241
"d",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timeline-arrows",
3-
"version": "4.3.0",
3+
"version": "4.3.1",
44
"description": "Package to easily draw lines to connect items in the vis Timeline module.",
55
"main": "arrow.js",
66
"types": "arrow.d.ts",

0 commit comments

Comments
 (0)