CSS3 Rotate on animated element causing click event not to invoke

我的梦境 提交于 2019-12-05 04:08:36

I cannot seem to replicate the problem, it seems to be working correctly after adding a float:left;.

Sometimes browsers act funny while rendering the actual width of an HTML element. float:left seems to make the browsers calculate better.

This is the JavaScript :

$(document).ready(function (){
  $('#box1').bind({
    'click' : function () {
      alert('clicked box 1');
    },
    'hover' : function () {
      console.log('Over Box 1');
    }
  });
  $('#box2').click(function(){
    alert('clicked box 2');
  });

  window.angle = 0;
  setInterval(function () {
    if (window.angle >= 360) {
      window.angle = 0;
    } else {
      window.angle += 5;
    }
    $('#box1').css('-webkit-transform', 'rotateY(' + window.angle + 'deg)');
    }, 100);
});

Here is an updated fiddle with the animation, it seems to work fine : http://jsfiddle.net/RyvtZ/9/

(I added console.log on hover to make life simpler ;) )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!