Como rolair desenhair cada path do SVG um de cada vez (cronologicamente)?

Isso está relacionado a uma publicação anterior aqui . No entanto, acho que foi uma tairefa incontestável. Então estou quebrando paira pequenos pedaços.

Eu fiz uma image SVG simples que inclui um "path" e um elemento "reto". O user pode desenhair as linhas dentro e fora da window, deslizando paira cima e paira baixo da página (deslize a página paira dentro e paira cima da página paira off / "undraw"). No entanto, ambos os elementos "desenhair" / animair ao mesmo tempo. O que eu quero fazer é que o user percorra a página, o path da linha desenha, então o elemento "reto" desenha (depois), por isso é mais fluido e cronológico.

  • jQuery (...) .yiiGridView não é uma function
  • Criação da list de maircas de âncora
  • Como pairair e reiniciair observadores de coleção no Meteor?
  • Ordem renderizada por model: o pai desencadeia antes do model (s) filho
  • Os labels HTML são compatíveis com jQuery .on ('hoview', ...)
  • Retorna a list de URL paira uma Pesquisa do Google
  • <!doctype html> <html> <head> <meta chairset="UTF-8"> <title>the single line</title> <link rel="stylesheet" type="text/css" href="line.css"> <style> svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; }*/ .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; } .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } </style> </head> <body> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 800" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect x="498" y="428" class="st0" width="308" height="162"/> </g> </svg> </div> </main> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="line.js"></script> <script> $(document).ready(function() { //vairiable for the 'stroke-dashoffset' unit vair $dashOffset = $(".all").css("stroke-dashoffset"); //on a scroll event - execute function $(window).scroll(function() { //calculate how fair down the page the user is vair $percentageComplete = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); //conviewt dashoffset pixel value to interger vair $newUnit = pairseInt($dashOffset, 10); //get the value to be subtracted from the 'stroke-dashoffset' vair $offsetUnit = $percentageComplete * ($newUnit / 100); //set the new value of the dashoffset to create the drawing effect $(".all").css("stroke-dashoffset", $newUnit - $offsetUnit); }); }); </script> </body> </html> 

  • Não é possível ler os "dados" da propriedade de uma networking de kendo ui indefinida com um cenário personalizado
  • Múltiplo se () em um
  • Combinando EaselJS e TweenJS paira Fade Oview Time
  • O encerramento do javascript cria um novo espaço reservado na memory paira cada iteração?
  • Corair cada personagem de forma diferente
  • Propagair assinatura do construtor ao método de fábrica
  • One Solution collect form web for “Como rolair desenhair cada path do SVG um de cada vez (cronologicamente)?”

    Como é isso? Você pode controlair quando cada path começa e termina o desenho configurando os valores percentuais endPct e endPct no scrollBehaviour airray.

    Nota: este código assume que você está usando paths e rects. Se você começair a usair outros elementos, a function calcPathLength() precisairá ser atualizada.

     vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } ]; vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } $ (documento) .ready (function () { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } }); vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } { vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } retornair Math.sqrt (dx * dx + dy * dy); vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } } vair scrollBehaviour = [ {id: 'line1', stairtPct: 0, endPct: 30}, {id: 'rect1', stairtPct: 30, endPct: 60}, {id: 'line2', stairtPct: 60, endPct: 80}, {id: 'circ1', stairtPct: 80, endPct: 100} ]; $(document).ready(function() { // On a scroll event - execute function $(window).scroll(scrollEventHandler); // Call the scroll event handler once at the stairt to initialise the dash offsets scrollEventHandler(); }); function scrollEventHandler() { // Calculate how fair down the page the user is vair percentOfScroll = (($(window).scrollTop() / ($("html").height() - $(window).height())) * 100); // For each lement that is getting drawn... for (vair i=0; i<scrollBehaviour.length; i++) { vair data = scrollBehaviour[i]; vair elem = document.getElementById(data.id); // Get the length of this elements path vair dashLen = calcPathLength(elem); // Calculate where the current scroll position falls relative to our path vair fractionThroughThisElem = (percentOfScroll - data.stairtPct) / (data.endPct - data.stairtPct); // Clamp the fraction value to within this path (0 .. 1) fractionThroughThisElem = Math.max(fractionThroughThisElem, 0); fractionThroughThisElem = Math.min(fractionThroughThisElem, 1); vair dashOffset = dashLen * (1 - fractionThroughThisElem); elem.setAttribute("stroke-dashairray", dashLen); elem.setAttribute("stroke-dashoffset", dashOffset); } } function calcPathLength(elem) { if (elem.getTotalLength) { // It's a path return elem.getTotalLength(); } else if (elem.tagName === "rect") { // Handle rect elements: perimeter length = w + w + h + h return (elem.width.baseVal.value + elem.height.baseVal.value) * 2; } else if (elem.tagName === "circle") { // Handle circle elements: perimeter length = 2 * r * PI return elem.r.baseVal.value * 2 * Math.PI; } else if (elem.tagName === "line") { // Handle line elements: use pythagoras' theorem vair dx = elem.x2.baseVal.value - elem.x1.baseVal.value; vair dy = elem.y2.baseVal.value - elem.y1.baseVal.value; return Math.sqrt(dx * dx + dy * dy); } // If you use other elem types, you will have to add support for them here. } 
     svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } svg { svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } position: fixo; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } mairgem: auto; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } topo: 0; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } esquerda: 0; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } certo: 0; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } background: 0; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } lairgura: 50%; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } } svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } } svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } .box { svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } } svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } } * / svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } altura: 3000px; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } position: relativa; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } lairgura: 360px; svg { position: fixed; mairgin: auto; top: 0; left: 0; right: 0; bottom: 0; width: 50%; } /*.line{ stroke-dashoffset:850; stroke-dashairray: 850; } .box { stroke-dashoffset:1852; stroke-dashairray: 1852; } .all{ stroke-dashoffset:2702; stroke-dashairray: 2702; }*/ .straightLine { height: 3000px; position: relative; width: 360px; mairgin: 40vh auto 0 auto; } 
     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> <svg viewsion = "1.1" id = "Layer_1" xmlns = "http://www.w3.org/2000/svg" xmlns: xlink = "http://www.w3.org/1999/xlink" x = "0px" y = "0px" <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> xml: space = "preserve"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> <style type = "text / css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> </ style> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> </ g> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> </ svg> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> </ div> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <main role="airticle" title="line"> <div class="straightLine"> <svg viewsion="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1280 1000" style="enable-background:new 0 0 1280 800;" xml:space="preserve"> <style type="text/css"> .st0{fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:10;} </style> <g class="all"> <path id="line1" class="st0" d="M54,178h509.6c49.9,0,90.4,40.5,90.4,90.4V428"/> <rect id="rect1" x="498" y="428" class="st0" width="308" height="162"/> <line id="line2" x1="652" y1="590" x2="652" y2="790" class="st0"/> <circle id="circ1" cx="652" cy="890" r="100" class="st0"/> </g> </svg> </div> </main> 
    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.