1

I'm trying to animate the elements on my page using jquery and CSS.

The elements are created dynamically thus using jquery.

The issue that i have is that the elements do not animate properly at all. they are actually blinking and go and back/forth and then animating which is not wanted.

This is a working fiddle to explain the issue better:

https://jsfiddle.net/npvsrkcy/12/

This is the sort of animation I'm trying to achieve:

enter image description here

This is my entire jquery code:

$.each($('.images '), function(i, el){
    $(el).css({'opacity':0});
    setTimeout(function(){
       $(el).animate({

         '-webkit-animation-delay': i+'s',
         'animation-delay': i+'s',
         'opacity':1.0
       }, 450);
    },500 + ( i * 500 ));
//add delay 3s 
i+1000;
});

Could someone please advise on this issue?

1 Answer 1

1

This should be a good starting point for the effect you're looking for.

I moved the animation into a class. There's no need to specify css animation delay. Applying the class within the loop and timeout is all we need.

$.each($('.images '), function(i, el){
    setTimeout(function(){
       $(el).addClass('animate');
    },500 + ( i * 500 ));
//add delay 3s 
i+1000;
});

https://jsfiddle.net/8kpzwtoz/

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

1 Comment

Perfecto amigo :) appreciate it.

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.