Bug 1380291 - Add .onboarding-opened and append notification bar inside requestAnimationFrame draft
authorFischer.json <fischer.json@gmail.com>
Thu, 13 Jul 2017 15:05:01 +0800
changeset 609308 127ef97fdf706a9552e3e3d2120a1de4b15bedff
parent 608658 67cd1ee26f2661fa5efe3d952485ab3c89af4271
child 637544 8e0efb31a86eb90c7f66f7c32fe56a6a7242823e
push id68547
push userbmo:fliu@mozilla.com
push dateSat, 15 Jul 2017 06:06:11 +0000
bugs1380291
milestone56.0a1
Bug 1380291 - Add .onboarding-opened and append notification bar inside requestAnimationFrame MozReview-Commit-ID: EXsFBA8Gt13
browser/extensions/onboarding/content/onboarding.js
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -585,27 +585,29 @@ class Onboarding {
       return;
     }
     let targetTourId = queue[0];
     let targetTour = this._tours.find(tour => tour.id == targetTourId);
 
     // Show the target tour notification
     this._notificationBar = this._renderNotificationBar();
     this._notificationBar.addEventListener("click", this);
-    this._window.document.body.appendChild(this._notificationBar);
-
     this._notificationBar.dataset.targetTourId = targetTour.id;
     let notificationStrings = targetTour.getNotificationStrings(this._bundle);
     let actionBtn = this._notificationBar.querySelector("#onboarding-notification-action-btn");
     actionBtn.textContent = notificationStrings.button;
     let tourTitle = this._notificationBar.querySelector("#onboarding-notification-tour-title");
     tourTitle.textContent = notificationStrings.title;
     let tourMessage = this._notificationBar.querySelector("#onboarding-notification-tour-message");
     tourMessage.textContent = notificationStrings.message;
-    this._notificationBar.classList.add("onboarding-opened");
+
+    this._window.requestAnimationFrame(() => {
+      this._notificationBar.classList.add("onboarding-opened");
+      this._window.document.body.appendChild(this._notificationBar);
+    });
 
     let params = [];
     if (startQueueLength != queue.length) {
       // We just change tour so update the time, the count and the queue
       params.push({
         name: "browser.onboarding.notification.last-time-of-changing-tour-sec",
         value: Math.floor(Date.now() / 1000)
       });