How to use the dom-helpers/contains function in dom-helpers

To help you get started, we’ve selected a few dom-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alcedo-ui / alcedo-ui / src / Drawer / Drawer.js View on Github external
drawerVisibleHandler = (el, drawerEl, currentVisible, isBlurClose) => {

        // el is missing
        if (el && !domContains(document, el)) {
            return currentVisible;
        }

        if (drawerEl && el && domContains(drawerEl, el)) {
            return currentVisible;
        }

        return isBlurClose ? false : currentVisible;

    };
github alcedo-ui / alcedo-ui / src / Popup / Popup.js View on Github external
triggerHandler = (el, triggerEl, popupEl, currentVisible, isBlurClose) => {

        // el is missing
        if (el && !domContains(document, el)) {
            return currentVisible;
        }

        if ((triggerEl && el && domContains(triggerEl, el))
            || (popupEl && el && domContains(popupEl, el))) {
            return currentVisible;
        }

        return isBlurClose ? false : currentVisible;

    };
github alcedo-ui / alcedo-ui / src / _vendors / TriggerPopCalculation.js View on Github external
}
        case Position.RIGHT_BOTTOM: {
            result.left = leftHorizontalRight(triggerEl, triggerOffset);
            result.top = topHorizontalBottom(triggerEl, triggerOffset, popupEl);
            break;
        }
        case Position.CENTER: {
            result.left = leftVerticalCenter(triggerEl, triggerOffset, popupEl);
            result.top = topHorizontalMiddle(triggerEl, triggerOffset, popupEl);
            break;
        }
    }

    // to solve the fixed parent element problem
    const closestFixedEl = Dom.getClosestFixed(triggerEl);
    if (closestFixedEl && parentEl && domContains(parentEl, closestFixedEl)) {
        result.position = 'fixed';
    }

    return result;

}
github intljusticemission / react-big-calendar / src / Selection.js View on Github external
}

    const { clientX, clientY, pageX, pageY } = getEventCoordinates(e)
    let node = this.container(),
      collides,
      offsetData

    // Right clicks
    if (
      e.which === 3 ||
      e.button === 2 ||
      !isOverContainer(node, clientX, clientY)
    )
      return

    if (!this.globalMouse && node && !contains(node, e.target)) {
      let { top, left, bottom, right } = normalizeDistance(0)

      offsetData = getBoundsForNode(node)

      collides = objectsCollide(
        {
          top: offsetData.top - top,
          left: offsetData.left - left,
          bottom: offsetData.bottom + bottom,
          right: offsetData.right + right,
        },
        { top: pageY, left: pageX }
      )

      if (!collides) return
    }
github intljusticemission / react-big-calendar / src / Selection.js View on Github external
_handleTerminatingEvent(e) {
    const { pageX, pageY } = getEventCoordinates(e)

    this.selecting = false

    this._removeEndListener && this._removeEndListener()
    this._removeMoveListener && this._removeMoveListener()

    if (!this._initialEventData) return

    let inRoot = !this.container || contains(this.container(), e.target)
    let bounds = this._selectRect
    let click = this.isClick(pageX, pageY)

    this._initialEventData = null

    if (e.key === 'Escape') {
      return this.emit('reset')
    }

    if (!inRoot) {
      return this.emit('reset')
    }

    if (click && inRoot) {
      return this._handleClickEvent(e)
    }
github intljusticemission / react-big-calendar / src / Selection.js View on Github external
function isOverContainer(container, x, y) {
  return !container || contains(container, document.elementFromPoint(x, y))
}
github react-bootstrap / react-overlays / src / useRootClose.js View on Github external
e => {
      const currentTarget = ref && ('current' in ref ? ref.current : ref);
      warning(
        !!currentTarget,
        'RootClose captured a close event but does not have a ref to compare it to. ' +
          'useRootClose(), should be passed a ref that resolves to a DOM node',
      );

      preventMouseRootCloseRef.current =
        !currentTarget ||
        isModifiedEvent(e) ||
        !isLeftClickEvent(e) ||
        contains(currentTarget, e.target);
    },
    [ref],
github AndriySvyryd / UnicornHack / src / UnicornHack.Web / ClientApp / src / components / TooltipTrigger.tsx View on Github external
handleMouseOverOut(handler: (e: React.MouseEvent) => void, e: React.MouseEvent) {
        const target = e.currentTarget as EventTarget;
        const related = e.relatedTarget;

        if ((!related || related !== target) && !contains(target as Element, related as Element)) {
            handler(e);
        }
    }
github react-bootstrap / react-overlays / src / Modal.js View on Github external
autoFocus() {
    if (!this.props.autoFocus) return;

    const currentActiveElement = activeElement(ownerDocument(this));

    if (this.dialog && !contains(this.dialog, currentActiveElement)) {
      this.lastFocus = currentActiveElement;
      this.dialog.focus();
    }
  }