Adam.V
Adam.V

Reputation: 789

Transform isn't working with jQuery .animate()

I noticed that whenever I try to use transform with a jQuery animation in the css section, it doesn't go off. It is the only property not working for me.

I am trying to use:

$(myElement).animate({
    opacity: 1, 
    transform: "scale(1.5)"
}, 7000);

But the above code only passes the opacity animation, ignoring the transform.

Upvotes: 2

Views: 6046

Answers (2)

Cole Faraday
Cole Faraday

Reputation: 180

Using the .animate() function, this would work.

$(myElement).animate({
    height: ($(this).height()*1.5),
    width: ($(this).width()*1.5)
}, 7000);

Upvotes: 1

Cole Faraday
Cole Faraday

Reputation: 180

One solution would be to use css for the animation and jquery to add the class that does the animation.

$(myElement).addClass("animate");
.animate {
  transition: all 7s;
  transform: scale(1.5);
}

Upvotes: 2

Related Questions