How to use svg-pan-zoom library with Angular4?

拈花ヽ惹草 提交于 2019-12-13 03:53:08

问题


 window.onload = function() {
  svgPanZoom('#demo-tiger', {
    zoomEnabled: true,
    controlIconsEnabled: true
  });
};

the above code doesn't work with Angular ??


回答1:


I have used svg-pan-zoom 3.5.x version, following code snippet may help you to import the library.

    // Psuedo angular TS code

    import * as SvgPanZoom from 'svg-pan-zoom';

    @Component({
      selector: 'app-svg-container',
      templateUrl: './svg-container.component.html',
      styleUrls: ['./svg-container.component.scss']
    })
    export class SvgContainerComponent implements OnInit, AfterViewInit {

      constructor() { }

      ngOnInit() {  }

      ngAfterViewInit() {
        // initializing the function
        let svgPanZoom: SvgPanZoom.Instance = SvgPanZoom('#wolrd-map-svg', this.options);
     /* see typing definiton for more APIs. */

      }

        ... More Codes...

    }


来源:https://stackoverflow.com/questions/46455932/how-to-use-svg-pan-zoom-library-with-angular4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!