CSS Transition 回呼
問題:
問題:是否可以在以下情況下收到通知CSS 轉場有完成?
答案:歌劇: oTransitionEnd
建議使用超時回退,以確保事件處理程序被調用,以防事件未按如下方式觸發
const transitionEndEventName = "XXX"; // Determine the appropriate event name const elemToAnimate = ...; // Element to animate let done = false; const transitionEnded = () => { done = true; // Transition finished actions elemToAnimate.removeEventListener(transitionEndEventName, transitionEnded, false); }; elemToAnimate.addEventListener(transitionEndEventName, transitionEnded, false); // Trigger animation setTimeout(() => { if (!done) { console.log("Timeout required to call transition ended."); transitionEnded(); } }, XXX); // Replace XXX with animation duration plus a grace period
以上是如何偵測 CSS 轉換是否完成?的詳細內容。更多資訊請關注PHP中文網其他相關文章!