Bug 1915230 - Make animation and duration configurable. r=#sidebar-reviewers CLOSED TREE

And tweak the default duration as per UX feedback.

Differential Revision: https://phabricator.services.mozilla.com/D221718

Depends on D221351
This commit is contained in:
Emilio Cobos Álvarez 2024-09-12 19:14:23 +00:00
Родитель cd125d358b
Коммит f4bdb58b5a
3 изменённых файлов: 18 добавлений и 16 удалений

Просмотреть файл

@ -1982,6 +1982,8 @@ pref("pdfjs.handleOctetStream", true);
// Is the sidebar positioned ahead of the content browser
pref("sidebar.position_start", true);
pref("sidebar.revamp", false);
pref("sidebar.animation.enabled", true);
pref("sidebar.animation.duration-ms", 200);
pref("sidebar.main.tools", "aichat,syncedtabs,history");
pref("sidebar.verticalTabs", false);
pref("sidebar.visibility", "always-show");

Просмотреть файл

@ -166,6 +166,7 @@ class TestSessionRestore(SessionStoreTestCase):
self.marionette.execute_script(
"""
Services.prefs.setBoolPref("sidebar.revamp", true);
Services.prefs.setBoolPref("sidebar.animation.enabled", false);
Services.prefs.setStringPref("sidebar.visibility", "always-show");
"""
)
@ -182,7 +183,6 @@ class TestSessionRestore(SessionStoreTestCase):
"""
const window = BrowserWindowTracker.getTopWindow();
window.SidebarController.toolbarButton.click();
window.SidebarController.sidebarMain.expanded = true;
return window.SidebarController.sidebarMain.expanded;
"""
),
@ -203,19 +203,7 @@ class TestSessionRestore(SessionStoreTestCase):
self.marionette.execute_script(
"""
const window = BrowserWindowTracker.getTopWindow();
function waitForExpandedState() {
let expanded = false;
for (let i = 0; i < 50; i++) {
if (!window.SidebarController.sidebarMain.expanded) {
continue;
} else {
expanded = true;
break;
}
}
return expanded;
}
return waitForExpandedState();
return window.SidebarController.sidebarMain.expanded;
"""
),
"Sidebar expanded state has been restored.",

Просмотреть файл

@ -838,7 +838,7 @@ var SidebarController = {
});
const options = {
duration: 300,
duration: this._animationDurationMs,
};
let animations = [];
let sidebarOnLeft = this._positionStart != RTL_UI;
@ -908,7 +908,7 @@ var SidebarController = {
async handleToolbarButtonClick() {
switch (this.sidebarRevampVisibility) {
case "always-show":
if (!window.gReduceMotion) {
if (this._animationEnabled && !window.gReduceMotion) {
this._animateSidebarMain();
} else {
this.toggleExpanded();
@ -1500,6 +1500,18 @@ XPCOMUtils.defineLazyPreferenceGetter(
}
}
);
XPCOMUtils.defineLazyPreferenceGetter(
SidebarController,
"_animationEnabled",
"sidebar.animation.enabled",
true
);
XPCOMUtils.defineLazyPreferenceGetter(
SidebarController,
"_animationDurationMs",
"sidebar.animation.duration-ms",
200
);
XPCOMUtils.defineLazyPreferenceGetter(
SidebarController,
"sidebarRevampEnabled",