I have a svg file on my website that drows in scroll, but I would like the animation start from particular section, can you help me please ?
Code JS :
$(document).ready(function() {
var myline = document.getElementById("myline");
var length = myline.getTotalLength();
myline.style.strokeDasharray = length;
myline.style.strokeDashoffset = length;
window.addEventListener("scroll", myFunction);
function myFunction() {
var scrollpercent = (document.body.scrollTop + document.documentElement.scrollTop) / (document.documentElement.scrollHeight - document.documentElement.clientHeight);
var draw = length * scrollpercent;
myline.style.strokeDashoffset = length - draw;
endPoint = myline.getPointAtLength(draw);
}
});
Thank you !