Skip to content

Commit 4f36b7d

Browse files
author
Michael Mrowetz
committed
add overlay offset
1 parent bbf33d5 commit 4f36b7d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: src/ts/waterfall/row/svg-tooltip.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@ import { addClass, getParentByClassName, removeClass } from "../../helpers/dom";
22
import * as svg from "../../helpers/svg";
33
import { RectData } from "../../typing/rect-data";
44

5+
const translateYRegEx = /translate\(\d+[, ]+(\d+)\)/;
6+
7+
const getTranslateY = (str: string = "") => {
8+
const res = translateYRegEx.exec(str);
9+
if (res && res.length >= 2) {
10+
return parseInt(res[1], 10);
11+
}
12+
return 0;
13+
};
14+
515
/** static event-handler to show tooltip */
616
export const onHoverInShowTooltip = (base: SVGRectElement, rectData: RectData, foreignEl: SVGForeignObjectElement) => {
717
console.log("onHoverInShowTooltip");
818
const offsetX = 5;
919
let offsetY = 5;
1020
const innerDiv = foreignEl.firstElementChild as HTMLDivElement;
21+
const row = getParentByClassName(base, "row-item") as SVGAElement;
22+
const yTransformOffest = getTranslateY(row.getAttribute("transform"));
1123
const y = base.getAttribute("y");
12-
const yNum = parseInt(y, 10);
24+
const yNum = parseInt(base.getAttribute("y"), 10);
1325
let x = base.getAttribute("x");
1426
const xPercInt = parseFloat(x);
1527
const rowWidth = base.width.baseVal.value || base.getBoundingClientRect().width;
@@ -41,7 +53,7 @@ export const onHoverInShowTooltip = (base: SVGRectElement, rectData: RectData, f
4153
} else {
4254
offsetY = -height;
4355
}
44-
foreignEl.style.transform = `translate(${offsetX}px, ${offsetY}px)`;
56+
foreignEl.style.transform = `translate(${offsetX}px, ${offsetY + yTransformOffest}px)`;
4557
foreignEl.setAttribute("height", height.toString());
4658
foreignEl.style.opacity = "1";
4759
// foreignEl.style.display = "block";

0 commit comments

Comments
 (0)