# All files / src/utils getCoordsFromEvent.js

45.45% Statements 5/11
66.67% Branches 4/6
100% Functions 1/1
50% Lines 5/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21

    2x
    2x
    2x

    2x
    2x

     // from @vx/brush
    export default function getCoordsFromEvent(node, event) {
      Iif (!node) return null;
      const svg = node.ownerSVGElement || node;
      Iif (svg.createSVGPoint) {
        let point = svg.createSVGPoint();
        point.x = event.clientX;
        point.y = event.clientY;
        point = point.matrixTransform(node.getScreenCTM().inverse());
        return {
          x: point.x,
          y: point.y,
        };
      }
      const rect = node.getBoundingClientRect();
      return {
        x: event.clientX - rect.left - node.clientLeft,
        y: event.clientY - rect.top - node.clientTop,
      };
    }