我想在影片結束時洗掉 dom,但我沒有在反應檔案 https://zh-hans.reactjs.org/docs/events.html#animation-events 中找到 onend 事件。
這是演示https://codesandbox.io/s/ecstatic-cherry-7nyh7r?file=/src/App.js
uj5u.com熱心網友回復:
我自己找到了路!
// jsx part
<animateMotion ref={handleMotionRef}></animateMotion>
// js part
function handleMotionRef(node) {
// node?.onend = () => {} or
node?.addEventListener(
'beginEvent',
(e) => {
e.target.parentNode.style.display = 'block';
},
false,
);
node?.addEventListener(
'endEvent',
(e) => {
e.target.parentNode.style.display = 'none';
},
false,
);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/476964.html
