javascript d3 不透明度转换 Flash 最终状态

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12308523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:53:18  来源:igfitidea点击:

d3 opacity transitions flash final state

javascriptd3.jstransition

提问by futuraprime

I have a number of basic opacity transitions along the lines of

我有一些基本的不透明度过渡

emp_line.transition()
    .duration(1250)
    .attr('opacity', 1)

However, when I run them, often these items will flash to full opacity and then back to none and fade in. Is there any way to prevent this content flickering?

但是,当我运行它们时,这些项目通常会闪烁到完全不透明,然后又变回无并淡入。有什么办法可以防止这些内容闪烁?

回答by nrabinowitz

Testing this, it looks like you get the flicker with .attr('opacity'), but not with .style('opacity'), so changing the transition to .style()should fix this.

对此进行测试,看起来您使用 闪烁.attr('opacity'),但使用 不闪烁.style('opacity'),因此将转换更改为.style()应该可以解决此问题。

Test fiddle: http://jsfiddle.net/nrabinowitz/Y5uX6/

测试小提琴:http: //jsfiddle.net/nrabinowitz/Y5uX6/

No idea why this should be true though :(.

不知道为什么这应该是真的:(。