SHARE
TWEET

Untitled

a guest Aug 12th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Polyfill SVG path support for iOS
  3.  */
  4. SVGCircleElement.prototype.getTotalLength = function() {
  5.   // Get the parent node width
  6.   // (trying to get the current node width returns 0)
  7.   let width = this.parentNode.clientWidth;
  8.  
  9.   // Get the radius by dividing by 2
  10.   let radius = width / 2;
  11.  
  12.   // Get the circumference from 2πr
  13.   let length = 2 * Math.PI * radius;
  14.  
  15.   // Return the calculated value
  16.   return length;
  17. }
RAW Paste Data
Top