g6Extensions.ts 608 B

123456789101112131415161718192021222324252627282930
  1. import { register, ExtensionCategory, Polyline } from '@antv/g6';
  2. class AntLine extends Polyline {
  3. private anim: any = null;
  4. onCreate() {
  5. const shape = this.shapeMap.key;
  6. this.anim = shape.animate([{ lineDashOffset: 20 }, { lineDashOffset: 20 }], {
  7. duration: 500,
  8. iterations: Infinity,
  9. });
  10. }
  11. onDestroy() {
  12. if (this.anim) {
  13. this.anim.cancel();
  14. this.anim = null;
  15. }
  16. }
  17. }
  18. try {
  19. register(ExtensionCategory.EDGE, 'ant-line', AntLine);
  20. } catch (e) {
  21. // 忽略重复注册
  22. console.debug('[G6] Custom edge "ant-line" already registered.');
  23. }
  24. export {};