Skip to content

Fix sidebar toggle flickering on page load #1868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.