Created
December 25, 2014 07:41
-
-
Save ihortkachuk/4bc5a7ea68d846d701f2 to your computer and use it in GitHub Desktop.
Заполняшка
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).scroll(function() { | |
drawLines(); | |
}); | |
//If you have more than one SVG per page this will pick it up | |
function drawLines(){ | |
$.each($("path"), function(i, val){ | |
var line = val; | |
drawLine($(this), line); | |
}); | |
} | |
//draw the line | |
function drawLine(container, line){ | |
var length = 0; | |
var pathLength = line.getTotalLength(); | |
var distanceFromTop = container.offset().top - $(window).scrollTop(); | |
var percentDone = 1 - (distanceFromTop / $(window).height()); | |
length = percentDone * pathLength; | |
line.style.strokeDasharray = [length,pathLength].join(' '); | |
console.log("strokeDasharray: "+[length,pathLength].join(' ')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment