Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 974c508

Browse files
UX: call discourseLater on menu animations (discourse#24168)
* UX: add discourseLater call to add breathing room for animation Allow for smoother animations on lower end devices. Create time between render and animations. extend panel width targets by 20 px to account for shadows as well
1 parent 360289e commit 974c508

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

app/assets/javascripts/discourse/app/components/site-header.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SwipeEvents from "discourse/lib/swipe-events";
99
import Docking from "discourse/mixins/docking";
1010
import RerenderOnDoNotDisturbChange from "discourse/mixins/rerender-on-do-not-disturb-change";
1111
import { isTesting } from "discourse-common/config/environment";
12+
import discourseLater from "discourse-common/lib/later";
1213
import { bind, observes } from "discourse-common/utils/decorators";
1314

1415
const SiteHeaderComponent = MountWidget.extend(
@@ -23,7 +24,7 @@ const SiteHeaderComponent = MountWidget.extend(
2324
_topic: null,
2425
_itsatrap: null,
2526
_applicationElement: null,
26-
_PANEL_WIDTH: 320,
27+
_PANEL_WIDTH: 340,
2728
_swipeEvents: null,
2829

2930
@observes(
@@ -387,7 +388,14 @@ const SiteHeaderComponent = MountWidget.extend(
387388

388389
headerCloak.animate([{ opacity: 0 }], { fill: "forwards" });
389390
headerCloak.style.display = "block";
390-
animationFinished.then(() => this._animateOpening(panel));
391+
392+
animationFinished.then(() => {
393+
if (isTesting()) {
394+
this._animateOpening(panel);
395+
} else {
396+
discourseLater(() => this._animateOpening(panel));
397+
}
398+
});
391399
}
392400

393401
this._animate = false;

app/assets/javascripts/discourse/app/widgets/header.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import { scrollTop } from "discourse/mixins/scroll-top";
1111
import { avatarImg } from "discourse/widgets/post";
1212
import RenderGlimmer from "discourse/widgets/render-glimmer";
1313
import { createWidget } from "discourse/widgets/widget";
14+
import { isTesting } from "discourse-common/config/environment";
1415
import getURL from "discourse-common/lib/get-url";
1516
import { iconNode } from "discourse-common/lib/icon-library";
17+
import discourseLater from "discourse-common/lib/later";
1618
import I18n from "discourse-i18n";
1719

1820
const SEARCH_BUTTON_ID = "search-button";
@@ -358,15 +360,21 @@ createWidget("revamped-hamburger-menu-wrapper", {
358360
const headerCloak = document.querySelector(".header-cloak");
359361
const finishPosition =
360362
document.querySelector("html").classList["direction"] === "rtl"
361-
? "320px"
362-
: "-320px";
363+
? "340px"
364+
: "-340px";
363365
panel
364366
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
365367
duration: 200,
366368
fill: "forwards",
367369
easing: "ease-in",
368370
})
369-
.finished.then(() => this.sendWidgetAction("toggleHamburger"));
371+
.finished.then(() => {
372+
if (isTesting()) {
373+
this.sendWidgetAction("toggleHamburger");
374+
} else {
375+
discourseLater(() => this.sendWidgetAction("toggleHamburger"));
376+
}
377+
});
370378
headerCloak.animate([{ opacity: 0 }], {
371379
duration: 200,
372380
fill: "forwards",
@@ -409,15 +417,21 @@ createWidget("revamped-user-menu-wrapper", {
409417
const headerCloak = document.querySelector(".header-cloak");
410418
const finishPosition =
411419
document.querySelector("html").classList["direction"] === "rtl"
412-
? "-320px"
413-
: "320px";
420+
? "-340px"
421+
: "340px";
414422
panel
415423
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
416424
duration: 200,
417425
fill: "forwards",
418426
easing: "ease-in",
419427
})
420-
.finished.then(() => this.closeUserMenu());
428+
.finished.then(() => {
429+
if (isTesting) {
430+
this.closeUserMenu();
431+
} else {
432+
discourseLater(() => this.closeUserMenu());
433+
}
434+
});
421435
headerCloak.animate([{ opacity: 0 }], {
422436
duration: 200,
423437
fill: "forwards",

0 commit comments

Comments
 (0)