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