d3-transition

Transition生命周期

Immediately after creating a transition, such as by selection.transition or transition.transition, you may configure the transition using methods such as transition.delay, transition.duration, transition.attr and transition.style. Methods that specify target values (such as transition.attr) are evaluated synchronously; however, methods that require the starting value for interpolation, such as transition.attrTween and transition.styleTween, must be deferred until the transition starts.
使用selection.transition或transition.transition創(chuàng)建一個(gè)transition之后,緊跟著可以配置transition.delay, transition.duration, transition.attr和transition.style。指定目標(biāo)值的方法,如transition.attr和transition.style會(huì)被同步調(diào)用;然而,需要起始值做插值的方法,如transition.attrTween和transition.styleTween,會(huì)被推遲到transition start后。

Shortly after creation, either at the end of the current frame or during the next frame, the transition is scheduled. At this point, the delay and start event listeners may no longer be changed.
transition創(chuàng)建后不久,在當(dāng)前幀結(jié)束或下一幀期間,transition is scheduled。此時(shí),delay和start事件可能不再被改變。

When the transition subsequently starts, it interrupts the active transition of the same name on the same element, if any, dispatching an interrupt event to registered listeners. (Note that interrupts happen on start, not creation, and thus even a zero-delay transition will not immediately interrupt the active transition: the old transition is given a final frame. Use selection.interrupt to interrupt immediately.) The starting transition also cancels any pending transitions of the same name on the same element that were created before the starting transition. The transition then dispatches a start event to registered listeners. This is the last moment at which the transition may be modified: after starting, the transition’s timing, tweens, and listeners may no longer be changed. The transition initializes its tweens immediately after starting.
transition start,隨后,它interrupt同元素上同名的active transition(如果有的話),向注冊(cè)的listeners分派一個(gè)interrupt事件。(注意,interrupt在start時(shí)發(fā)生,而不是creation,因此即使一個(gè)無(wú)延遲的transition不會(huì)立即interrupt當(dāng)前的active transition: old transition is given a final frame。使用selection.interrupt立即interrupt。)在開(kāi)始starting transition之前也會(huì)取消同元素上同名的任何等候的transition。然后,transition向注冊(cè)的listeners分派一個(gè)start事件。這是可以修改transition的最后時(shí)刻:當(dāng)starting后,transition的timing,tweens和listeners可能不再被改變。transition在starting后立即初始化tweens。

During the frame the transition starts, but after all transitions starting this frame have been started, the transition invokes its tweens for the first time. Batching tween initialization, which typically involves reading from the DOM, improves performance by avoiding interleaved DOM reads and writes.
在transition starts期間,在所有transition starting之后,transition將第一次調(diào)用tweens。批處理執(zhí)行tween初始化(通常涉及從DOM讀?。ㄟ^(guò)避免交叉DOM讀寫操作來(lái)提高性能。

For each frame that a transition is active, it invokes its tweens with an eased t-value ranging from 0 to 1. Within each frame, the transition invokes its tweens in the order they were registered.
transition是active的每個(gè)frame,調(diào)用它的tween方法,使用從0到1d的eased t值。在每個(gè)frame中,transition按照注冊(cè)時(shí)的順序調(diào)用tweens。

When a transition ends, it invokes its tweens a final time with a (non-eased) t-value of 1. It then dispatches an end
event to registered listeners. This is the last moment at which the transition may be inspected: after ending, the transition is deleted from the element, and its configuration is destroyed. (A transition’s configuration is also destroyed on interrupt or cancel.)
當(dāng)transition結(jié)束時(shí),它最后一次調(diào)用tweens,使用1作為t值(non-eased)。然后向注冊(cè)的listeners分派一個(gè)end事件。這是transition可以被inspected的最后一刻:ending之后,transition在元素中被刪掉,并且銷毀其配置(transition的配置在interrupt或cancel時(shí)也會(huì)被銷毀)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容