Animate element when in viewport with isVisible? #354
-
Hi, thanks for a great plugin. Is it possible to get an example on how I would animate elements when they come into the viewport? I Guess i use isVisible but I can't get it to work.
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Here's an old demo about isVisible method: http://jsbin.com/noxoho/edit?js Hope it could help you :) |
Beta Was this translation helpful? Give feedback.
-
@idiotWu thanks, perfect=) |
Beta Was this translation helpful? Give feedback.
-
@idiotWu This only fires when you interact with the scrollbar, what about if the element is at the top of the page or partially showing? try to get some functionality similar to waypoint.js |
Beta Was this translation helpful? Give feedback.
-
@adamwright32 I don't understand what you mean by "interact with the scrollbar". The smooth-scrollbar/src/geometry/is-visible.ts Lines 3 to 14 in 8ff9227 |
Beta Was this translation helpful? Give feedback.
-
@idiotWu but thats only triggered when you are listening to the scrollbar. So if the page loads and you don't scroll it won't fire. Or maybe i'm doing it wrong
|
Beta Was this translation helpful? Give feedback.
-
@adamwright32 no you don't have to put it in the scroll listener. It's a static check and you can run it everywhere. |
Beta Was this translation helpful? Give feedback.
-
Is there a way for scrollbar.isVisible(element) to check if the element isVisible on page load without scrolling? Reference example: http://jsbin.com/hujugirexi/edit?html,js,output (I re-ordered the divs in your previous example, such that "content" is on top). "content" only shows "visible: true" when scrolling at least once (even though it is visible upon page load). Thanks for the help. |
Beta Was this translation helpful? Give feedback.
-
@dtab428 simply call |
Beta Was this translation helpful? Give feedback.
-
Hi, can you please give us an example on windows load? |
Beta Was this translation helpful? Give feedback.
Here's an old demo about isVisible method: http://jsbin.com/noxoho/edit?js
Hope it could help you :)