1 回答

TA貢獻1872條經驗 獲得超4個贊
begin和end時間,如果在不引用其他時鐘的情況下使用,則始終引用文檔的開頭。0s因此,您應該使用其他參考,而不是將該值設置為。我想到了幾種可能性:
從點擊或其他事件開始。該begin值采用以下形式<id of event target element>.<event name>:
<rect id="grafic" height={5} width={5}>
<animate id="animation" attributeName="height"
from={5} to={10} dur="2s" begin="grafic.click"/>
</rect>
從其他一些代碼開始。該begin值保持在indefinite:
<rect id="grafic" height={5} width={5}>
<animate id="animation" attributeName="height"
from={5} to={10} dur="2s" begin="indefinite"/>
</rect>
但動畫是通過 API 調用啟動的:
document.getElementById('animation').beginElement();
為了獲得更像 React 的感覺,請在設置屬性時定義“立即”的 wallckock 值:
const rightnow = () => new Date().toLocaleTimeString()
<rect id="grafic" height={5} width={5}>
<animate id="animation" attributeName="height"
from={5} to={10} dur="2s"
begin={start ? `wallclock(${rightnow()})` : "indefinite"/>
</rect>
添加回答
舉報