Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script can be used to achieve a SVG-Animation-Effect similar to the one on http://www.polygon.com/a/ps4-review It takes all paths in an SVG-Element, hides them and draws them into the page. The method is explained in http://product.voxmedia.com/post/68085482982/polygon-feature-design-svg-animations-for-fun-and An example can be found at htt…
//inspired by http://product.voxmedia.com/post/68085482982/polygon-feature-design-svg-animations-for-fun-and
function drawSVGPaths() {
'use strict';
//grab all PATHs from an SVG-Element
var paths = $('.svganimate path');
//for each PATH..
$.each( paths, function() {
//get the total length
var totalLength = this.getTotalLength();
//set PATHs to invisible
$(this).css({
'stroke-dashoffset': totalLength,
'stroke-dasharray': totalLength + ' ' + totalLength
});
//animate
$(this).animate({
'stroke-dashoffset': 0
}, 1200);
});
}
drawSVGPaths();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.