JQuery UI bounce effect - bounce only once when entering a div

I have a div that I want to bounce once when the mouse enters / hovers over the div.

The code I use in Chrome but not in Firefox or IE.

http://jsfiddle.net/d7UjD/73/

In Chrome, it bounces once at will, but in FF and IE bouncing continues as long as the mouse stays in place.

I also tried $('#box').one("mouseenter", function() {, but the box bounces once, and subsequent entries in the div have no effect.

Any thoughts on why browsers behave differently and what can I do about it?

+5
source share
1 answer

LIVE DEMO

$("#box").hover(function(){
if ( !$(this).data("bouncing") ){
      $(this).effect("bounce", { direction: 'up', distance: 10, times: 1 })
             .data("bouncing", true);
}
},function () {
     $(this).data("bouncing", false);
});

, data true boolean,
if true false.
- false, hover ... !:)

:

$("#box").on('mouseenter mouseleave',function( e ) {
  var el = $(this);
  if(!el.data("b"))el.effect("bounce", {direction:'up',distance:10,times:1} );
  el.data("b",e.type=="mouseenter"?true:false);
});
+11

All Articles