Skip to content

Commit

Permalink
Fix sidebar toggle flickering on page load (#1868)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonprev authored Feb 20, 2024
1 parent e305f27 commit 5962468
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
13 changes: 5 additions & 8 deletions assets/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ body {
}

.sidebar-button {
--sidebarButtonRightOpen: 4px;
position: fixed;
z-index: 200;
top: 0;
left: 0;
transition: all var(--sidebarTransitionDuration) ease-in-out;
will-change: transform;
margin-top: 10px;
}

.sidebar-toggle--animated.sidebar-button {
transition: transform var(--sidebarTransitionDuration) ease-in-out;
}

.content {
Expand All @@ -73,7 +74,7 @@ body {
}

body:is(.sidebar-opening, .sidebar-opened) .sidebar-button {
transform: translateX(calc(var(--sidebarWidth) - 100% - var(--sidebarButtonRightOpen)));
transform: translateX(calc(var(--sidebarWidth) - 100%));
}

body.sidebar-opening-start .sidebar {
Expand Down Expand Up @@ -121,10 +122,6 @@ body.sidebar-closed .content {
left: 0;
}

body.sidebar-closed .sidebar-button {
margin: 10px 8px;
}

@media screen and (max-width: 768px) {
.content,
body.sidebar-opening .content {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
cursor: pointer;
background-color: transparent;
border: none;
padding: 18px 8px 18px 11px;
padding: 28px 12px 18px 19px;
font-size: var(--sidebarFontSize);
}

Expand Down
3 changes: 3 additions & 0 deletions assets/js/sidebar/sidebar-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ function setDefaultSidebarState () {
setClass(SIDEBAR_CLASS.opened)
qs(SIDEBAR_TOGGLE_SELECTOR).setAttribute('aria-expanded', 'true')
}

// apply transition after the default state has been set so the animation does not show on initial page load
setTimeout(() => qs(SIDEBAR_TOGGLE_SELECTOR).classList.add('sidebar-toggle--animated'), ANIMATION_DURATION)
}

function isScreenSmall () {
Expand Down

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions formatters/html/dist/html-elixir-2O34B7FU.css

This file was deleted.

6 changes: 6 additions & 0 deletions formatters/html/dist/html-elixir-4FQOSVKU.css

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions formatters/html/dist/html-erlang-GIY63A7R.css

This file was deleted.

6 changes: 6 additions & 0 deletions formatters/html/dist/html-erlang-I77ZGSQD.css

Large diffs are not rendered by default.

0 comments on commit 5962468

Please sign in to comment.