0

I have this animation that makes some buttons on screen 'beat'. It works fine exept one thing, the animation is too 'sharp' and not smooth, how can I smooth it?

function myFunction() { setInterval(function () { tstFnc(); }, 1000); } var flag = true; function tstFnc() { var numM = Math.floor((Math.random() * 10) + 1); var stringM = '#mgf_main' + numM + ' img'; $(stringM).animate({ width: '80px', height: '80px' }, 150, function () { $(stringM).animate({ width: '68px', height: '68px' }, 150, function () { // nothing }); }); }; 

2 Answers 2

2

You can set the easing property on the animate options.

http://api.jquery.com/animate/

http://easings.net/

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

1 Comment

If you read on you'll see a description and link for the jQuery Easing Plugin
0

Try this here, animatethis is a function and target element is the id of element and speed is depend on you.. and marginleft is a example, you should try your code.

function animatethis(targetElement, speed) { $(targetElement).animate({ width: "+=10px", height: "+=10px"}, { duration: speed, complete: function () { targetElement.animate({width: "+=10px", height: "+=10px" }, { duration: speed, complete: function () { animatethis(targetElement, speed); } }); } }); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.