Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply CSS transition when element comes into viewport [closed]

I'm trying to apply CSS transition effect when an element comes to viewport (i.e. when user scrolls to it), but not before.

I already know how to use CSS transitions, but how do I apply them only when the element comes to viewport?

What it the best way of doing this? If there's some library's to simplify the task, I would be glad to know.

like image 445
ZeiZei Avatar asked Jan 22 '14 15:01

ZeiZei


People also ask

How do you trigger transition CSS?

Triggering transitions You can trigger CSS transitions directly with pseudo classes like :hover (activates when the mouse goes over an element), :focus (activates when a user tabs onto an element, or when a user clicks into an input element), or :active (activates when user clicks on the element).

Does transition work only on hover?

This will animate the color property when you hover over a link on the page. Pretty simple, and you've probably seen or used something similar. But transitions are not just limited to use with :hover . You can animate CSS properties, thus use CSS transitions without hover.


2 Answers

Give CSS3 Animate It a go, makes the whole process as simple as adding a few clases.

http://jackonthe.net/css3animateit/

Then you can just add the classes like this to get started.

<div class='animatedParent'> <h2 class='animated bounceInDown'>It Works!</h2> </div>   
like image 159
Jack Avatar answered Oct 17 '22 09:10

Jack


Here is a great demo:

Slide In (as you scroll down) Boxes | CSS-Tricks http://bit.ly/19NN2NJ
Slide in from bottom boxes - CodePen http://bit.ly/1dvNF9U

Maybe it helps you to see point. Point is detect a viewport and apply effect just onScroll as you can see in demo. If you want help with bug or specific problem just send a source :-) and I'll solve.

like image 22
Samuel Ondrek Avatar answered Oct 17 '22 10:10

Samuel Ondrek