How to use the dom-lib.getWidth 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-table / src / Table.js View on Github external
calculateTableContentWidth(prevProps: Props) {
    const table = this.table;
    const row = table.querySelector(`.${this.addPrefix('row')}:not(.virtualized)`);
    const contentWidth = row ? getWidth(row) : 0;

    this.setState({ contentWidth });
    // 这里 -SCROLLBAR_WIDTH 是为了让滚动条不挡住内容部分
    this.minScrollX = -(contentWidth - this.state.width) - SCROLLBAR_WIDTH;

    /**
     * 1.判断 Table 列数是否发生变化
     * 2.判断 Table 内容区域是否宽度有变化
     *
     *
     * 满足 1 和 2 则更新横向滚动条位置
     */

    if (
      _.flatten(this.props.children).length !== _.flatten(prevProps.children).length &&
      this.state.contentWidth !== contentWidth
github rsuite / rsuite / src / Slider / Slider.tsx View on Github external
getWidth() {
    if (this.barRef.current) {
      return getWidth(this.barRef.current);
    }
    return 0;
  }
github rsuite / rsuite / src / Slider / Slider.tsx View on Github external
setTooltipPosition() {
    const { tooltip } = this.props;

    if (tooltip) {
      const handle = this.handleRef.current;
      const tip = handle.querySelector(`.${this.addPrefix('tooltip')}`);
      const width = getWidth(tip);
      addStyle(tip, 'left', `-${width / 2}px`);
    }
  }
github rsuite / rsuite-table / src / Table.js View on Github external
calculateTableWidth = () => {
    const table = this.table;
    const { width } = this.state;
    if (table) {
      const nextWidth = getWidth(table);

      if (width !== nextWidth) {
        this.scrollX = 0;
        this.scrollbarX && this.scrollbarX.resetScrollBarPosition();
      }

      this._cacheCells = null;
      this.setState({
        width: nextWidth
      });
    }
    this.setAffixHeaderOffset();
  };
github rsuite / rsuite / src / RangeSlider / RangeSlider.tsx View on Github external
getWidth() {
    if (this.barRef.current) {
      return getWidth(this.barRef.current);
    }
    return 0;
  }
github rsuite / rsuite / src / _picker / MenuWrapper.js View on Github external
updateMenuStyle() {
    const { getToggleInstance } = this.props;

    if (this.menuElement && getToggleInstance) {
      const instance = getToggleInstance();
      if (instance && instance.toggle) {
        const width = getWidth(findDOMNode(instance.toggle));
        addStyle(this.menuElement, 'min-width', `${width}px`);
      }
    }
  }
  handleResize = () => {