Canvas: Fix ability to draw arrows (#77573)
Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
This commit is contained in:
co-authored by
Adela Almasan
parent
a4744a8f5e
commit
fb2b1c2e13
@@ -88,6 +88,12 @@ export const ConnectionAnchors = ({ setRef, handleMouseLeave }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
id={id}
|
id={id}
|
||||||
|
ref={(element) => {
|
||||||
|
if (element) {
|
||||||
|
// After React 15+, inline styles no longer support !important
|
||||||
|
element.style.setProperty('pointer-events', 'auto', 'important');
|
||||||
|
}
|
||||||
|
}}
|
||||||
key={id}
|
key={id}
|
||||||
alt={CONNECTION_ANCHOR_ALT}
|
alt={CONNECTION_ANCHOR_ALT}
|
||||||
className={styles.anchor}
|
className={styles.anchor}
|
||||||
@@ -131,7 +137,6 @@ const getStyles = (theme: GrafanaTheme2) => ({
|
|||||||
width: `calc(5px + 2 * ${ANCHOR_PADDING}px)`,
|
width: `calc(5px + 2 * ${ANCHOR_PADDING}px)`,
|
||||||
height: `calc(5px + 2 * ${ANCHOR_PADDING}px)`,
|
height: `calc(5px + 2 * ${ANCHOR_PADDING}px)`,
|
||||||
zIndex: 100,
|
zIndex: 100,
|
||||||
pointerEvents: 'auto',
|
|
||||||
}),
|
}),
|
||||||
highlightElement: css({
|
highlightElement: css({
|
||||||
backgroundColor: '#00ff00',
|
backgroundColor: '#00ff00',
|
||||||
|
|||||||
@@ -204,12 +204,13 @@ export const calculateCoordinates = (
|
|||||||
|
|
||||||
if (info.targetName) {
|
if (info.targetName) {
|
||||||
const targetRect = target.div?.getBoundingClientRect();
|
const targetRect = target.div?.getBoundingClientRect();
|
||||||
|
if (targetRect) {
|
||||||
|
const targetHorizontalCenter = targetRect.left - parentRect.left + targetRect.width / 2;
|
||||||
|
const targetVerticalCenter = targetRect.top - parentRect.top + targetRect.height / 2;
|
||||||
|
|
||||||
const targetHorizontalCenter = targetRect!.left - parentRect.left + targetRect!.width / 2;
|
x2 = targetHorizontalCenter + (info.target.x * targetRect.width) / 2;
|
||||||
const targetVerticalCenter = targetRect!.top - parentRect.top + targetRect!.height / 2;
|
y2 = targetVerticalCenter - (info.target.y * targetRect.height) / 2;
|
||||||
|
}
|
||||||
x2 = targetHorizontalCenter + (info.target.x * targetRect!.width) / 2;
|
|
||||||
y2 = targetVerticalCenter - (info.target.y * targetRect!.height) / 2;
|
|
||||||
} else {
|
} else {
|
||||||
const parentHorizontalCenter = parentRect.width / 2;
|
const parentHorizontalCenter = parentRect.width / 2;
|
||||||
const parentVerticalCenter = parentRect.height / 2;
|
const parentVerticalCenter = parentRect.height / 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user