Browser sometimes ignores a jQuery click event during a CSS3 transform

后端 未结 1 1557
天命终不由人
天命终不由人 2021-01-18 07:58

When an element contains another element that is being animated via a CSS transition, click events are occasionally not fired.

Test case: http://codepe

相关标签:
1条回答
  • 2021-01-18 08:34

    I think that the key is disabling mouse events in the p elements:

    p {
      pointer-events: none;
    }
    

    the problem arises because the click is generated from a mousedown + a mouseup, and if you do it in the edge of the transition the mousedown is in one element and the mouseup in another (and that doesn't generate the click).

    The other way around (not really the same, but most probably the users won't notice it) is doing it in mousedown instead of click

    0 讨论(0)
提交回复
热议问题