Skip to content

Instantly share code, notes, and snippets.

@ihortkachuk
Created December 25, 2014 07:41
Show Gist options
  • Save ihortkachuk/4bc5a7ea68d846d701f2 to your computer and use it in GitHub Desktop.
Save ihortkachuk/4bc5a7ea68d846d701f2 to your computer and use it in GitHub Desktop.
Заполняшка
$(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