3

I was trying apply jQuery easing plugin to .css and .animate, but not working, i dont know why, because normally it works. Code example:

$('#img').hover(function() {
    $(this).animate({"border-radius":"5px"}, 0, "easeOutBounce");
}, function() {
    $(this).animate({"border-radius":"75px"}, 0, "easeOutBounce");
});

So basically .animate (instead of .css to avoid problems) but i want also set animation duration and working "easeOutBounce" or some of other effects.

Now border radius is animated on :hover, but without animation timing.

I cannot do it in css, and jQuery is not working, is there some way to fix this?

Thanks, Oliver

Oliver
  • 341
  • 2
  • 4
  • 21

3 Answers3

2

I think the syntax you are using in your animation is not correct. Also, you need to set a duration > 0 if you want to see something.

Feel free to change the easing part with your own plugin.

$('#img').hover(
  function() {
    $(this).animate({
      borderRadius: 75
    }, 300, 'easeOutBounce');
  },
  function() {
    $(this).animate({
      borderRadius: 5
    }, 300, 'easeOutBounce');
  }
);
#img {
  border-radius: 5px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>

<img id="img" src="https://i.stack.imgur.com/Qk0jX.jpg">
Pingolin
  • 3,161
  • 6
  • 25
  • 40
  • Thanks, but its not working with effect.. for example i want easeOutBounce, (http://gsgd.co.uk/sandbox/jquery/easing/) and it not works :/ . – Oliver Jan 06 '19 at 15:21
  • Is possible make this timing effect.. in jquery? If plugin not works with .animate (idk why) – Oliver Jan 06 '19 at 15:22
  • Hi @Oliver, I changed the easing to `easeOutBounce`, you can check in my snippet. – Pingolin Jan 07 '19 at 07:35
1

This function should work:

$('#img').hover(
  function() {
    $(this).animate({
      borderRadius: 75
    }, 300, 'easeOutBounce');
  },
  function() {
    $(this).animate({
      borderRadius: 5
    }, 300, 'easeOutBounce');
  }
);
0

try to modify timing effects like ease out bounce

change it to ease in

Vickel
  • 7,879
  • 6
  • 35
  • 56