How to use the dom-lib.getOffset function in dom-lib

To help you get started, we’ve selected a few dom-lib 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 rsuite / rsuite / src / utils / overlayPositionUtils.js View on Github external
calcOverlayPosition(placement, overlayNode, target, container, padding) {

        const childOffset = utils.getPosition(target, container);
        const { height: overlayHeight, width: overlayWidth } = getOffset(overlayNode);

        let positionLeft, positionTop, arrowOffsetLeft, arrowOffsetTop;

        if (placement === 'left' || placement === 'right') {
            positionTop = childOffset.top + (childOffset.height - overlayHeight) / 2;

            if (placement === 'left') {
                positionLeft = childOffset.left - overlayWidth;
            } else {
                positionLeft = childOffset.left + childOffset.width;
            }

            const topDelta = getTopDelta(positionTop, overlayHeight, container, padding);

            positionTop += topDelta;
            arrowOffsetTop = 50 * (1 - 2 * topDelta / overlayHeight) + '%';
github rsuite / rsuite / src / Slider / Slider.tsx View on Github external
updatePosition(event: React.MouseEvent) {
    const { vertical, min, locale } = this.props;
    const barOffset = getOffset(this.barRef.current);
    const offset = vertical ? event.pageY - barOffset.top : event.pageX - barOffset.left;
    const value = locale.rtl && !vertical ? barOffset.width - offset : offset;

    this.setValue(this.calculateValue(value) + min);
  }
github rsuite / rsuite-table / src / Scrollbar.js View on Github external
setTimeout(() => {
      this.bar &&
        this.setState({
          barOffset: getOffset(this.bar)
        });
    }, 1);
  }
github rsuite / rsuite / src / RangeSlider / RangeSlider.tsx View on Github external
getValueByPosition = (event: React.MouseEvent) => {
    const { vertical, min, locale } = this.props;
    const barOffset = getOffset(this.barRef.current);
    const offset = vertical ? event.pageY - barOffset.top : event.pageX - barOffset.left;
    const value = locale.rtl && !vertical ? barOffset.width - offset : offset;

    return this.getValueByOffset(value) + min;
  };
github rsuite / rsuite-table / src / Table.js View on Github external
this.setState(() => {
        return { affixHeaderOffset: getOffset(this.headerWrapper) };
      });
    }
github rsuite / rsuite / src / utils / overlayPositionUtils.js View on Github external
getContainerDimensions(containerNode) {
        let width, height, scroll;
        if (containerNode.tagName === 'BODY') {
            width = window.innerWidth;
            height = window.innerHeight;
            scroll = scrollTop(ownerDocument(containerNode).documentElement) || scrollTop(containerNode);
        } else {
            ({ width, height } = getOffset(containerNode));
            scroll = scrollTop(containerNode);
        }
        return { width, height, scroll };
    },
github rsuite / rsuite / src / Affix / Affix.tsx View on Github external
this.setState(() => {
      return { offset: getOffset(this.containerRef.current) };
    });
  };
github rsuite / rsuite / src / Ripple / Ripple.tsx View on Github external
getPosition = (event: React.MouseEvent) => {
    const offset = getOffset(this.triggerRef.current);
    const offsetX = (event.pageX || 0) - offset.left;
    const offsetY = (event.pageY || 0) - offset.top;

    const radiusX = Math.max(offset.width - offsetX, offsetX);
    const radiusY = Math.max(offset.height - offsetY, offsetY);
    const radius = Math.sqrt(Math.pow(radiusX, 2) + Math.pow(radiusY, 2));

    return {
      width: radius * 2,
      height: radius * 2,
      left: offsetX - radius,
      top: offsetY - radius
    };
  };