How to use the dom-lib.getPosition 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
getPosition(target, container) {
        const offset = container.tagName === 'BODY' ? getOffset(target) : getPosition(target, container);
        return offset;
    },
github rsuite / rsuite / src / Picker / DropdownMenu.tsx View on Github external
updateScrollPoistion() {
    const container = this.menuBodyContainerRef.current;
    let activeItem = container.querySelector(`.${this.addPrefix('item-focus')}`);

    if (!activeItem) {
      activeItem = container.querySelector(`.${this.addPrefix('item-active')}`);
    }

    if (!activeItem) {
      return;
    }
    const position = getPosition(activeItem, container);
    const sTop = scrollTop(container);
    const sHeight = getHeight(container);
    if (sTop > position.top) {
      scrollTop(container, Math.max(0, position.top - 20));
    } else if (position.top > sTop + sHeight) {
      scrollTop(container, Math.max(0, position.top - sHeight + 32));
    }
  }
github rsuite / rsuite / src / Calendar / TimeDropdown.tsx View on Github external
Object.entries(time).forEach((item: any) => {
      const container: Element = this.container[item[0]];
      const node = container.querySelector(`[data-key="${item[0]}-${item[1]}"]`);
      if (node && container) {
        const { top } = getPosition(node, container);
        scrollTopAnimation(this.container[item[0]], top, scrollTop(this.container[item[0]]) !== 0);
      }
    });
  };
github rsuite / rsuite / src / Cascader / DropdownMenu.tsx View on Github external
this.menus.forEach(menu => {
      if (!menu) {
        return;
      }

      let activeItem = menu.querySelector(`.${this.addPrefix('item-focus')}`);

      if (!activeItem) {
        activeItem = menu.querySelector(`.${this.addPrefix('item-active')}`);
      }

      if (activeItem) {
        const position = getPosition(activeItem, menu);
        scrollTop(menu, position.top);
      }
    });
  }