0

I am using the animate.css classes on my page. Currently I have all animations built on hover function.

For example:

#folder:hover .middle-button{
            animation-name: slideRight;
            animation-duration: 1s; 
            animation-timing-function: ease-in-out;     
            visibility: visible !important; 
        }

I would like to activate these animation classes on scroll and my question is:

What would be the easiest way to trigger this class using a Javascript function?

3
  • possible duplicate of Trigger events when the window is scrolled to certain positions Commented Aug 14, 2014 at 4:32
  • I assume you want to add class when the element appears on the viewport? Commented Aug 14, 2014 at 5:50
  • Yes, this is correct. So I would like add a class when the element appears on the viewport. I have several div classes on the page that are using different animations. The animation for each div have been already added on the CSS sheet and I just need to understand how to trigger these animated classes if the element appears on viewport. Commented Aug 14, 2014 at 6:18

1 Answer 1

1

This is the best I can do: http://codepen.io/zvona/pen/ovDbk

It will add class visible to all the elements with className onAppear.

So, you can add class for all the elements that you want to animate on appear:

<div class="onAppear">This will be animated.</div>

And then on CSS (transition example, not animation - figure it out by yourself):

.onAppear {
  transition: transform 500ms;
}

.onAppear.visible {
  transform: translate3d(250px, 0px, 0px);
}

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Great, I got it to work now as you can see here: codepen.io/anon/pen/Afqza Now the problem is that I would like only the handle class element to animate on viewport, now the whole SVG does the animation. Any ideas how can I fix that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.