How to use the @antv/dom-util.getWidth function in @antv/dom-util

To help you get started, we’ve selected a few @antv/dom-util 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 antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
public forceFit() {
    if (this.destroyed) {
      return;
    }
    const width = domUtil.getWidth(this.domContainer);
    const height = this.height;
    if (width !== this.domWidth) {
      const canvas = this.canvas;
      canvas.changeSize(width, height); // 改变画布尺寸
      if (this.bgChart) {
        this.bgChart.changeSize(width, this.bgChart.get('height'));
      }
      canvas.clear();
      this._initWidth();
      this._initSlider(); // 初始化滑动条
      this._bindEvent();
      canvas.draw();
    }
  }
  public _initForceFitEvent() {
github antvis / G2 / packages / component / src / tooltip / canvas.ts View on Github external
public setPosition(oldx: number, oldy: number, target?: any) {
    // todo
    let x = oldx;
    let y = oldy;
    const container = this.get('container');
    const outterNode = this.get('canvas').get('el');
    const viewWidth = domUtil.getWidth(outterNode);
    const viewHeight = domUtil.getHeight(outterNode);
    const bbox = container.getBBox();
    const containerWidth = bbox.width;
    const containerHeight = bbox.height;

    let endx = x;
    let endy = y;

    let position;
    if (this.get('position')) {
      position = defaultPosition(x, y, this.get('position'), containerWidth, containerHeight, target);
      x = position[0];
      y = position[1];
    } else {
      position = constraintPositionInBoundary(x, y, containerWidth, containerHeight, viewWidth, viewHeight);
      x = position[0];
github antvis / G2 / packages / component / src / tooltip / html.ts View on Github external
public setPosition(oldx: number, oldy: number, target?: any) {
    // todo any 是 Shape
    let x = oldx;
    let y = oldy;
    const container = this.get('container');
    const outterNode = this.get('canvas').get('el');
    const viewWidth = domUtil.getWidth(outterNode);
    const viewHeight = domUtil.getHeight(outterNode);
    let containerWidth = container.clientWidth;
    let containerHeight = container.clientHeight;

    let endx = x;
    let endy = y;

    let position;
    const prePosition = this.get('prePosition') || { x: 0, y: 0 };

    // @2019-01-30 by blue.lb 由于display:none的元素获取clientWidth和clientHeight的值为0,这里强制显隐一下,其实直接在show和hide中去掉display设置最好,猜测为了更好的兼容浏览器
    if (!containerWidth) {
      container.style.display = 'block';
      containerWidth = container.clientWidth;
      containerHeight = container.clientHeight;
      container.style.display = 'none';
github antvis / G2 / packages / g2 / src / plot / plot.ts View on Github external
private forceFit() {
    if (this.destroyed) {
      return;
    }
    const container = this._getContainerDOM();
    const oldWidth = this.get('width');
    const width = domUtil.getWidth(container, oldWidth);
    if (width !== 0 && width !== oldWidth) {
      const height = this.get('height');
      this.changeSize(width, height);
    }
    return this;
  }
  private _getContainerDOM() {
github antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
public _initWidth() {
    let width;
    if (this.width === 'auto') {
      width = domUtil.getWidth(this.domContainer);
    } else {
      width = this.width;
    }
    this.domWidth = width;
    const padding = parsePadding(this.padding);

    if (this.layout === 'horizontal') {
      this.plotWidth = width - padding[1] - padding[3];
      this.plotPadding = padding[3];
      this.plotHeight = this.height;
    } else if (this.layout === 'vertical') {
      this.plotWidth = this.width;
      this.plotHeight = this.height - padding[0] - padding[2];
      this.plotPadding = padding[0];
    }
  }
github antvis / G2 / packages / g2 / src / plot / plot.ts View on Github external
private _initCanvas() {
    const canvas = new Canvas({
      containerDOM: this.get('containerDOM'),
      containerId: this.get('containerId'),
      width: this.get('width'),
      height: this.get('height'),
      renderer: this.get('renderer'),
      pixelRatio: this.get('pixelRatio'),
    });
    this.set('canvas', canvas);
    this.set('container', canvas);
    if (this.get('forceFit')) {
      const container = this._getContainerDOM();
      const width = domUtil.getWidth(container, this.get('width'));
      this.set('width', width);
    }
  }
  private _initEvents() {