-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Delay animations until attached #7370
Conversation
I didn't look super closely, but the overall idea seems reasonable to me.
Is that something that would be hard to implement?
This part seemed unexpected to me. I'd expect that the bars in the codepen should be handled just like the normal initial animation reset case instead of a resize |
src/core/core.controller.js
Outdated
@@ -953,8 +961,10 @@ export default class Chart { | |||
} | |||
}; | |||
|
|||
me.platform.addEventListener(me, 'resize', listener); | |||
me.attached = me.platform.addEventListener(me, 'resize', listener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a breaking API change that we need to document now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a new return value is breaking, but it could be documented for sure.
Its not something you'd expect addEventListener
to return though, that's why I didn't bother to document it.
Maybe the logic should be moved to core from platform:
if (platform.isAttached(me)) {
platform.addEventListener(me, 'resize', ...)
platform.addEventListener(me, 'detach', ...)
} else {
platrofm.addEventListener(me, 'attach', ...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be a good strategy. It would allow for alternate implementations without returning from addEventListener
src/platform/platform.dom.js
Outdated
@@ -277,27 +277,28 @@ function unlistenForResize(proxies) { | |||
* @param {function} listener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring needs an update
* Delay animations until attached * Detect container detachment
Played around a bit with animation delaying, for issue #7290
Pen: https://codepen.io/kurkle/pen/MWaowYj
Update: added container attachment detection and also delayed initial update to happen after atteched.