import { register, ExtensionCategory, Polyline } from '@antv/g6';

class AntLine extends Polyline {
  private anim: any = null;

  onCreate() {
    const shape = this.shapeMap.key;
    this.anim = shape.animate([{ lineDashOffset: 20 }, { lineDashOffset: 20 }], {
      duration: 500,
      iterations: Infinity,
    });
  }

  onDestroy() {
    if (this.anim) {
      this.anim.cancel();
      this.anim = null;
    }
  }
}

try {
  register(ExtensionCategory.EDGE, 'ant-line', AntLine);
} catch (e) {
  // 忽略重复注册
  console.debug('[G6] Custom edge "ant-line" already registered.');
}

export {};
