-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transition interruption not behaving as expected #201
Comments
Thanks for the report. In order to understand what the problem is I would need to see the code for the full sequence including the first rendering. That said; interrupting a transition is not something I've tested or even considered so you may well have found a real bug. |
Got it. I suspect something is waiting for the end event in the transition to happen. Calling element.__transition[group].timer.call(duration) on all elements does make the next transition start right away (but does jump to the end of the previous transition). I'll make a test repo soon then :). Thanks for this awesome module btw, I've been using it for years, great work! |
DemoOk, here is the minimalistic demo: |
Hack-fixFor what is worth, I played a bit with the internals and found a way to "fix-hack-it". I hope it helps finding out what the problem is: what it does
this way, when one calls const t = transition("reload")
.ease(easeCubic)
.duration(3000)
.on("interrupt", () => {
document.querySelectorAll("#graph *").forEach((node: any) => {
if (node.__data__?.attributes?.d && node.getAttribute("d"))
node.__data__.attributes.d = node.getAttribute("d");
if (node.__zoom) {
const match = node.firstElementChild
.getAttribute("transform")
.match(/(-?[\d.]+)/g);
if (match) {
const transform = match.map(Number)
if (transform[0]!==undefined)node.__zoom.x = transform[0];
if (transform[1]!==undefined)node.__zoom.y = transform[1];
if (transform[2]!==undefined)node.__zoom.k = transform[2];
}
}
});
const node = container as any;
var slots = node.__transition;
for (const self of Object.values(slots) as any) {
self.on.call("end", node, node.__data__, self.index, self.group);
}
}); interrupt call selectAll([container]).selectAll("*").interrupt("reload"); |
Thank you so much for this. I'll look into it as soon as I can carve out some time and mental space for it. |
Steps to reproduce:
Expected behaviour
Current behaviour
My rendering code
The text was updated successfully, but these errors were encountered: