Skip to content

Instantly share code, notes, and snippets.

@rickbutterfield
Last active November 25, 2020 18:03
Show Gist options
  • Save rickbutterfield/96427c4d1f36d659397dc6a1b8557010 to your computer and use it in GitHub Desktop.
Save rickbutterfield/96427c4d1f36d659397dc6a1b8557010 to your computer and use it in GitHub Desktop.
Polyfill getTotalLength support for SVG circles on iOS
/**
* Polyfill SVG path support for iOS
*/
SVGCircleElement.prototype.getTotalLength = function() {
let width = this.parentNode.clientWidth, // Get the parent node width (trying to get the current node width returns 0)
radius = width / 2, // Get the radius by dividing by 2
length = 2 * Math.PI * radius; // Get the circumference from 2πr
// Return the calculated value
return length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment