Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

responsive scale is now cross browser compatible (firefox did not update the svg.height / svg.width values)

Peter6b64c67d72e1
diff --git a/anime.js b/anime.js
index 453c693c..109ae612 100644
--- a/anime.js
+++ b/anime.js
@@ -518,8 +518,12 @@
var scaleX = 1;
var scaleY = 1;
if (typeof path.viewBox !== 'undefined' ) {
- scaleX = (path.svg.width.baseVal.value / path.viewBox.width);
- scaleY = (path.svg.height.baseVal.value / path.viewBox.height);
+ const box = path.svg.getBoundingClientRect();
+ const width = box.right-box.left; //path.svg.width.baseVal.value is not cross browser compatible
+ const height = box.bottom-box.top; //path.svg.height.baseVal.value is not cross browser compatible
+
+ scaleX = (width / path.viewBox.width);
+ scaleY = (height / path.viewBox.height);
}
const p = point();