mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 17:24:42 +08:00
UX: call discourseLater on menu animations (#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
This commit is contained in:
parent
360289e108
commit
974c508cc8
|
@ -9,6 +9,7 @@ import SwipeEvents from "discourse/lib/swipe-events";
|
||||||
import Docking from "discourse/mixins/docking";
|
import Docking from "discourse/mixins/docking";
|
||||||
import RerenderOnDoNotDisturbChange from "discourse/mixins/rerender-on-do-not-disturb-change";
|
import RerenderOnDoNotDisturbChange from "discourse/mixins/rerender-on-do-not-disturb-change";
|
||||||
import { isTesting } from "discourse-common/config/environment";
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
import discourseLater from "discourse-common/lib/later";
|
||||||
import { bind, observes } from "discourse-common/utils/decorators";
|
import { bind, observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
const SiteHeaderComponent = MountWidget.extend(
|
const SiteHeaderComponent = MountWidget.extend(
|
||||||
|
@ -23,7 +24,7 @@ const SiteHeaderComponent = MountWidget.extend(
|
||||||
_topic: null,
|
_topic: null,
|
||||||
_itsatrap: null,
|
_itsatrap: null,
|
||||||
_applicationElement: null,
|
_applicationElement: null,
|
||||||
_PANEL_WIDTH: 320,
|
_PANEL_WIDTH: 340,
|
||||||
_swipeEvents: null,
|
_swipeEvents: null,
|
||||||
|
|
||||||
@observes(
|
@observes(
|
||||||
|
@ -387,7 +388,14 @@ const SiteHeaderComponent = MountWidget.extend(
|
||||||
|
|
||||||
headerCloak.animate([{ opacity: 0 }], { fill: "forwards" });
|
headerCloak.animate([{ opacity: 0 }], { fill: "forwards" });
|
||||||
headerCloak.style.display = "block";
|
headerCloak.style.display = "block";
|
||||||
animationFinished.then(() => this._animateOpening(panel));
|
|
||||||
|
animationFinished.then(() => {
|
||||||
|
if (isTesting()) {
|
||||||
|
this._animateOpening(panel);
|
||||||
|
} else {
|
||||||
|
discourseLater(() => this._animateOpening(panel));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._animate = false;
|
this._animate = false;
|
||||||
|
|
|
@ -11,8 +11,10 @@ import { scrollTop } from "discourse/mixins/scroll-top";
|
||||||
import { avatarImg } from "discourse/widgets/post";
|
import { avatarImg } from "discourse/widgets/post";
|
||||||
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
||||||
import { createWidget } from "discourse/widgets/widget";
|
import { createWidget } from "discourse/widgets/widget";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import { iconNode } from "discourse-common/lib/icon-library";
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
|
import discourseLater from "discourse-common/lib/later";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
|
|
||||||
const SEARCH_BUTTON_ID = "search-button";
|
const SEARCH_BUTTON_ID = "search-button";
|
||||||
|
@ -358,15 +360,21 @@ createWidget("revamped-hamburger-menu-wrapper", {
|
||||||
const headerCloak = document.querySelector(".header-cloak");
|
const headerCloak = document.querySelector(".header-cloak");
|
||||||
const finishPosition =
|
const finishPosition =
|
||||||
document.querySelector("html").classList["direction"] === "rtl"
|
document.querySelector("html").classList["direction"] === "rtl"
|
||||||
? "320px"
|
? "340px"
|
||||||
: "-320px";
|
: "-340px";
|
||||||
panel
|
panel
|
||||||
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
|
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
easing: "ease-in",
|
easing: "ease-in",
|
||||||
})
|
})
|
||||||
.finished.then(() => this.sendWidgetAction("toggleHamburger"));
|
.finished.then(() => {
|
||||||
|
if (isTesting()) {
|
||||||
|
this.sendWidgetAction("toggleHamburger");
|
||||||
|
} else {
|
||||||
|
discourseLater(() => this.sendWidgetAction("toggleHamburger"));
|
||||||
|
}
|
||||||
|
});
|
||||||
headerCloak.animate([{ opacity: 0 }], {
|
headerCloak.animate([{ opacity: 0 }], {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
|
@ -409,15 +417,21 @@ createWidget("revamped-user-menu-wrapper", {
|
||||||
const headerCloak = document.querySelector(".header-cloak");
|
const headerCloak = document.querySelector(".header-cloak");
|
||||||
const finishPosition =
|
const finishPosition =
|
||||||
document.querySelector("html").classList["direction"] === "rtl"
|
document.querySelector("html").classList["direction"] === "rtl"
|
||||||
? "-320px"
|
? "-340px"
|
||||||
: "320px";
|
: "340px";
|
||||||
panel
|
panel
|
||||||
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
|
.animate([{ transform: `translate3d(${finishPosition}, 0, 0)` }], {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
easing: "ease-in",
|
easing: "ease-in",
|
||||||
})
|
})
|
||||||
.finished.then(() => this.closeUserMenu());
|
.finished.then(() => {
|
||||||
|
if (isTesting) {
|
||||||
|
this.closeUserMenu();
|
||||||
|
} else {
|
||||||
|
discourseLater(() => this.closeUserMenu());
|
||||||
|
}
|
||||||
|
});
|
||||||
headerCloak.animate([{ opacity: 0 }], {
|
headerCloak.animate([{ opacity: 0 }], {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user