function calcInnerDistancesBetweenPointAndSidesOfElement(point, el) {
    // Even if the scrolling element is small it acts as a scroller for the viewport
    const rect =
        el === document.scrollingElement
            ? {
                  top: 0,
                  bottom: window.innerHeight,
                  left: 0,
                  right: window.innerWidth
              }
            : el.getBoundingClientRect();
    if (!isPointInsideRect(point, rect)) {
        return null;
    }
    return {
        top: point.y - rect.top,
        bottom: rect.bottom - point.y,
        left: point.x - rect.left,
        right: rect.right - point.x
    };
}
If the point is inside the element returns its distances from the sides, otherwise returns null
@param {Point} point
@param {HTMLElement} el
@return {null|{top: number, left: number, bottom: number, right: number}}