Start animation on progress bar when its visible on screen

后端 未结 3 920
青春惊慌失措
青春惊慌失措 2021-02-06 19:04

I want to create a webpage that contains several sections. In one of those sections are something like progress bars. These progress bars are \'animated\' so that the user sees

3条回答
  •  一个人的身影
    2021-02-06 19:15

    Here is a fiddle: http://jsfiddle.net/rAQev/4/

    I've used a comparison of scroll offset and your special section offset to detect a moment when this section becomes visible. Animations are queued to be processed one after another using jQuery queue function, you can read about it in jQuery docs (http://api.jquery.com/queue/). Also scroll event is unbinded when the first 'loading' happens, not to run 'loading' again and again on scroll event when section is visible.

提交回复
热议问题