D3转换 - 暂停和恢复 [英] D3 transitions - pause and resume

查看:117
本文介绍了D3转换 - 暂停和恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从此指南了解D3转换的暂停和恢复。虽然我明白暂停是如何工作的,但我在谈到简历时迷失了一点。我不能理解作者的解释,特别是线性或第一次简历说明。我的问题是什么是 e.attr(T,0); .attr(T,1); 完全正确?

I am trying to understand 'pause' and 'resume' for D3 transitions from this guide. While I understand how 'pause' is working, I am little lost when it comes to 'resume'. I couldn't make sense of the author's explanation, specifically the 'linear' or first resume explanation. My question is what is e.attr("T",0); and .attr("T",1); doing exactly?

我将恢复功能应用于视频或波形示例的播放头: jsfiddle

I am applying the resume functionality to a playhead for video or waveform example here: jsfiddle

推荐答案

代码 e .attr(T,0) .attr(T,1)设置所选节点的属性。也就是说,创建并设置新属性T。这样做的目的纯粹是为了方便停止和恢复 - 0表示开始之前的转换,1表示结束。

The code e.attr("T",0) and .attr("T",1) sets attributes for the node that is selected. That is, a new attribute "T" is created and set. The purpose of this is purely to facilitate stopping and resuming -- 0 represents a transition before start and 1 at the end.

如果此属性包含在转换中,值将从0逐渐变为1.正如本教程的作者指出的,这可以用于获取任何时间点的转换状态 - 您只需要查询T的值。如果您也保存特定的转​​换,您可以使用该值暂停和恢复在任何时候。

If this attribute is included in the transition, the value will gradually change from 0 to 1. As the author of the tutorial points out, this can be used to get the state of the transition at any point in time -- you simply need to query the value of "T". If you save the particular transition as well, you can use the value to pause and resume at any point.

请注意,没有什么特别的T。您可以使用任何(未使用)属性名称。目的只是有一些方法来告诉过渡的进展程度。

Note that there is nothing special about "T". You can use any (unused) attribute name. The purpose is only to have some way of telling how far the transition has progressed.

这篇关于D3转换 - 暂停和恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆