Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 48202a1

Browse files
committed
💄 Sidebar animations
1 parent e5ea185 commit 48202a1

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

‎src/browser/base/content/browser-sidebar-js.patch‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/base/content/browser-sidebar.js b/browser/base/content/browser-sidebar.js
2-
index eb1ee9e2b868fa06af4ed88e1d54583cd4196880..faa86a8037a36652e8507d631354e11a7852db07 100644
2+
index eb1ee9e2b868fa06af4ed88e1d54583cd4196880..4a4f2e926d2954003cd4b8cbacc318dc820f8cc8 100644
33
--- a/browser/base/content/browser-sidebar.js
44
+++ b/browser/base/content/browser-sidebar.js
55
@@ -2,10 +2,14 @@
@@ -179,7 +179,54 @@ index eb1ee9e2b868fa06af4ed88e1d54583cd4196880..faa86a8037a36652e8507d631354e11a
179179
/**
180180
* Opens the switcher panel if it's closed, or closes it if it's open.
181181
*/
182-
@@ -575,21 +681,31 @@ var SidebarUI = {
182+
@@ -457,6 +563,10 @@ var SidebarUI = {
183+
return this._show(commandID).then(() => {
184+
this._loadSidebarExtension(commandID);
185+
186+
+ // Pulse: Reset sidebar margin to zero to allow for correct animations to
187+
+ // take place (adapted from dot browser, se below)
188+
+ this._box.style.marginLeft = '0px'
189+
+
190+
if (triggerNode) {
191+
updateToggleControlLabel(triggerNode);
192+
}
193+
@@ -552,6 +662,25 @@ var SidebarUI = {
194+
195+
this.selectMenuItem("");
196+
197+
+ // The below code was, in part, based on Dot Browser's source code
198+
+ // https://github.com/dothq/browser-desktop/blob/3c6b992af8946e1c30180cc824a78d4bb85ba868/patches/browser-base-content-browser-sidebar-js.patch#L183
199+
+
200+
+ // Pulse Browser: Helper stuff for sidebar animation. We can fake sliding in
201+
+ // and out by changing the left margin to be a negative value. Then, inside
202+
+ // of our css code, we can animate it to close.
203+
+ this._box.style.marginLeft = `${-Math.abs(this._box.getBoundingClientRect().width)}px`
204+
+
205+
+ // We want to fully set it to hidden to slightly improve browser performance
206+
+ // when it is hidden. Note that this replaces some of Mozilla's code that
207+
+ // would generally be down below
208+
+ setTimeout(() => {
209+
+ this._box.hidden = true
210+
+ this._splitter.hidden = true
211+
+
212+
+ this._box.removeAttribute("checked")
213+
+ }, 170);
214+
+
215+
+
216+
// Replace the document currently displayed in the sidebar with about:blank
217+
// so that we can free memory by unloading the page. We need to explicitly
218+
// create a new content viewer because the old one doesn't get destroyed
219+
@@ -560,9 +689,6 @@ var SidebarUI = {
220+
this.browser.setAttribute("src", "about:blank");
221+
this.browser.docShell.createAboutBlankContentViewer(null, null);
222+
223+
- this._box.removeAttribute("checked");
224+
- this._box.hidden = this._splitter.hidden = true;
225+
-
226+
let selBrowser = gBrowser.selectedBrowser;
227+
selBrowser.focus();
228+
if (triggerNode) {
229+
@@ -575,21 +701,31 @@ var SidebarUI = {
183230
* none if the argument is an empty string.
184231
*/
185232
selectMenuItem(commandID) {

‎src/browser/themes/shared/sidebar_tabs.inc.css‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
max-width: var(--tab-min-height);
1818
min-width: var(--tab-min-height);
19+
20+
/* Makes the sidebar slide out from below */
21+
position: relative;
22+
z-index: 10;
1923
}
2024

2125
.sidebar-icon-item {
@@ -83,6 +87,11 @@
8387
-moz-font-smoothing-background-color: auto !important;
8488
}
8589

90+
/* Make it slide in smoothy rather than just appearing */
91+
#sidebar-box {
92+
transition: margin-left 200ms ease-in-out;
93+
}
94+
8695
/* Make it feel native on macos */
8796
%ifdef XP_MACOSX
8897
#sidebar-container:not([lwt-sidebar]) {

0 commit comments

Comments
 (0)