transitionend event fires twice

后端 未结 6 796
渐次进展
渐次进展 2020-12-04 19:33

I have the following code and my problem is that the transitionend event is fired twice. I don\'t know what\'s causing this. I suspected the vendor prefixes cau

6条回答
  •  臣服心动
    2020-12-04 20:28

    You can use the target property to filter out events that are triggered by child elements and use propertyName to only trigger the event when a specific property changed.

    const handleTransitionEnd = event => {
      if (event.target !== myDomElementRef) return;
      if (event.propertyName !== "height") return;
    
      // Do my things
    };
    

提交回复
热议问题