Comments (9)
Reproduction: http://bl.ocks.org/curran/cbd4695616e8128049e2614464c4140c
from d3-transition.
Bug reproduces in Chrome 51 and Firefox 47 but not in Safary.
from d3-transition.
This is the expected behavior because transition.style uses the computed value as the starting value (hence converting percentage to pixels), then followed by d3.interpolateString.
You can avoid this by using transition.styleTween and specifying the start value explicitly by returning an interpolator that both starts and ends with percentages.
I suppose an alternative solution would be for D3 to set the target value temporarily, compute the resulting computed value, and then use that for the interpolator. But that is a fairly significant change and also means that the resulting assigned style property value will be different than what was passed to transition.style when the transition ends. So I am inclined to close this as designed.
from d3-transition.
I'm not sure, note that in my case div.style("left")
is -4597.61px, but window.getComputedStyle(document.querySelector("div")).left
when left is set to -50% is -480px
from d3-transition.
Yes. That is because div.style("left") is again returning the computed value.
from d3-transition.
We already set the target value temporarily in the case of transition.style(name, null) so that we know how to transition when removing a style. I suppose it wouldn’t be too much of a stretch to temporarily set the style in all cases, so that transition.style uses the computed value for both the start and end. (Related bug #49.)
I’m a little worried that this will be detrimental to performance, especially since a naïve implementation would interleave reading and writing to the DOM and waste effort. But perhaps there’s a simple four-pass approach where, on all starting elements, we first read the starting computing values, then temporarily set the style to the target value, then read the ending computed values, and then finally restore to the starting value.
from d3-transition.
I don't think I get it, why not just interpolate value from node.style.left if it's presented to the end value without computing and converting to px? I think it's common situation when inline style is already set or set just before the transition.
from d3-transition.
from d3-transition.
I think it would be reasonable for style transitions to use the inline value if present as the starting value, and only fallback to the computed value if the inline value is not present. That way it’s a lot easier to control the starting value of a transition, and by extension the interpolator. Also, it’s more consistent with how attribute transitions work. And it’s faster!
from d3-transition.
Related Issues (20)
- transition.end() never resolves if 0 elements are matched HOT 2
- transition.easeVarying?
- [d3@6] transition.end() crashes HOT 3
- transitions are not iterable. HOT 1
- [v2.0.0] error: transition 1 not found HOT 4
- transition().style() fails to work as expected when applied to a starting property of 0px HOT 1
- transition().textTween not working HOT 1
- .end() with textTween causes uncaught promise when used at the same time as d3-force HOT 1
- transition.selectChild[ren] HOT 2
- Is there a way to control transition process?
- test 122 failure on Ubuntu HOT 2
- issues when doing .transition(t) HOT 6
- Can not bundle project with webpack minimize option. Cannot get final name for export 'easeCubicInOut' ... HOT 2
- Security patches
- Example for transition() isn't correct in READ.ME? HOT 2
- transition() prevents click events on iOS Safari/15.5 HOT 2
- Tranzicija
- Administrator
- d3-color version issue
- Opacity transition does not work properly for % values HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-transition.