Closed jordan-ware closed 6 years ago
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
Thanks for the PR. I'll review it tomorrow, can I ask you in the meantime to accepted our CLA?
Yeah, it says I have, but doesn't seem to be updating the status in this PR.
Sorry for the close, must've fat fingered something!
@jordan-ware thanks for the fix. Works great, I've just added some linter fixes while merging. Good job 👍
This fixes the race condition reported in #54 . There was a unit test for this specific scenario, however it was reporting a false positive because the CSS was using an incorrect name - in the actual execution of the test the animation wasn't used at all. Fixing the unit test reported an error on the original code. I then applied my fixes and the unit test began to pass. I've also tested the changes in my own project with various animation durations on add/remove.
Based on a discussion I saw with JODS and another maintainer (I think in templating github to do with ELSE implementation) I see that we want to prematurely end an animation instead of chaining them, so my changes include this which probably helps the race conditions as well. Developers can use the promises returned by the add/remove class to ensure the animations are chained instead if they want.
Here's a basic timeline of the add/remove overlap scenario before the fix:
addClass()
animation start:class-add
added50ms delay
removeClass() animation start:
class-remove
addedcurrent state:
class-remove
+class-add
applied to element.addClass()
animation end callback:class
addedclass-add
removedremoveClass()
animation end callback:class-remove
removedcurrent state:
class
is applied because of theaddClass()
end animation callback, but shouldn't be.