Skip to content

Instantly share code, notes, and snippets.

@rickbutterfield
rickbutterfield / polyfill.js
Last active November 25, 2020 18:03
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;