if(position.top >= 0 && position.bottom <= window.innerHeight)
window.addEventListener('scroll', function() {
let paths = document.querySelectorAll('[id=p]');
paths.forEach(function(path) {
var position = path.getBoundingClientRect();
if(position.top >= 0 && position.bottom <= window.innerHeight) {
setTimeout(function(){
const length = path.getTotalLength();
path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;
}, 2000);
}
});
});
window.onload=function(){
checkAnimationVisible();
}
window.addEventListener('scroll', function() {
checkAnimationVisible();
});
function checkAnimationVisible() {
let paths = document.querySelectorAll('[id=p]');
paths.forEach(function(path) {
var position = path.getBoundingClientRect();
if(position.top >= 0 && position.bottom <= window.innerHeight) {
setTimeout(function(){
const length = path.getTotalLength();
path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;
}, 2000);
}
});
}