javascript - svg-pan-zoom not working 100% of the time -


i use svg-pan-zoom library (https://github.com/ariutta/svg-pan-zoom), , works 75% of time on page on site (both in chrome , firefox, latest versions).

because im assuming due misconfiguration on part, wondering if made error, or if there specific scenario's may causing this.

my code:

(function (mw, $) {     $(document).ready(function () {          panzoominstance = svgpanzoom('#stylometricanalysis-svg1', {             zoomenabled: true,             controliconsenabled: true,             fit: true,             center: true,             minzoom: 0.1         });          panzoominstance = svgpanzoom('#stylometricanalysis-svg2', {             zoomenabled: true,             controliconsenabled: true,             fit: true,             center: true,             minzoom: 0.1         });      });  }(mediawiki, jquery)); 

the error:

145 typeerror: this.options.svg.createsvgmatrix not function  

library version: 3.2.9

<object class='stylometricanalysis-image' id='stylometricanalysis-svg1' type='image/svg+xml' data='/some/path/to/svg/file.svg'>your browser not support svg files, , visualization cannot display</object>  <object class='stylometricanalysis-image' id='stylometricanalysis-svg2' type='image/svg+xml' data='/some/path/to/svg/file.svg'>your browser not support svg files, , visualization cannot display</object> 

your svg content loaded dynamically. means svg content available when js kicks in, not. , when it's not - errors.

you have init svgpanzoom after svg content got loaded. check this example dynamic svgs see how can that. before initializing svgpanzoom have check if svg got loaded, , if not listen load event.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -