Bug 1417600 - Wait for a style flush before setting animation out to ensure start of the animation. r?jaws draft
authorXidorn Quan <me@upsuper.org>
Thu, 16 Nov 2017 10:33:04 -0800
changeset 702015 c070f1390232ca513f40c5ce90afcb5634e88b68
parent 702010 f0db16c419b4b9494a3b43442a4053adf1f8cb12
child 741335 80335016e12838c8e21bdf6fe61ddd0cb9424e7b
push id90347
push userxquan@mozilla.com
push dateWed, 22 Nov 2017 15:47:08 +0000
reviewersjaws
bugs1417600
milestone59.0a1
Bug 1417600 - Wait for a style flush before setting animation out to ensure start of the animation. r?jaws MozReview-Commit-ID: 96nGBDgdr05
browser/components/customizableui/CustomizeMode.jsm
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -603,16 +603,22 @@ CustomizeMode.prototype = {
       }
 
       function resolveAnimationPromise() {
         animationNode.removeEventListener("animationend", cleanupWidgetAnimationEnd);
         animationNode.removeEventListener("customizationending", cleanupCustomizationExit);
         resolve();
       }
 
+      // Force a style flush to ensure we do start the animation.
+      // (We cannot use promiseLayoutFlushed here because the callback
+      // is not invoked until any actual reflow gets triggered, which
+      // may not always happen soonish enough. If we have a style flush
+      // observer, we can probably use that, though.)
+      this.window.getComputedStyle(animationNode).animationName;
       animationNode.classList.add("animate-out");
       animationNode.ownerGlobal.gNavToolbox.addEventListener("customizationending", cleanupCustomizationExit);
       animationNode.addEventListener("animationend", cleanupWidgetAnimationEnd);
     });
   },
 
   async addToToolbar(aNode) {
     aNode = this._getCustomizableChildForNode(aNode);