Setting SVG start on scroll

I have an animated timeline svg that comes on the last section.

http://chalke-design-ebbca1.webflow.io/our-process

The animation starts as soon as the page is loaded but I want to trigger it only when the users scrolls to that specific part of the page.

Can anyone help!

Thank you in advance!


也许你需要这些问题中概述的内容:检查元素是否在屏幕上可见,或者在滚动后检查元素是否可见,即检查问题元素的顶部偏移量是否在屏幕边界内,然后启动你的动画如果条件成立的话。

var theElementInQuestion = document.getElementById("theElementInQuestion");

if (isScrolledIntoView(theElementInQuestion)) {
    startAnimation();
}

function isScrolledIntoView(elem)
{
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
链接地址: http://www.djcxy.com/p/83614.html

上一篇: 需要知道div的一部分是否可见

下一篇: 设置SVG从滚动开始