Skip to content

Commit

Permalink
use more performant CSS to animate sidebar
Browse files Browse the repository at this point in the history
This also fixes the layout shift that Chrome complained about,
although this is an intentional shift. This seems fishy, given it
being triggered by the user, and the shift occurring either way.

see https://web.dev/articles/carousel-best-practices
  • Loading branch information
breunigs committed Oct 11, 2023
1 parent 205d200 commit f4a655a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ $sidebarBoxShadowNormal: 0.1em 0 0.3em 0.1em rgba(0,0,0,0.3);
}

#sidebar {
left: max($minWidth, $mainWidth);
position: fixed;
transition: none !important;
}
Expand Down Expand Up @@ -493,12 +492,13 @@ body.showSidebar::before {
}

.showSidebar #sidebar {
left: min(100vw - $minWidth, $mainWidth);
// i.e. move the sidebar to the left by the difference of "expanded" minus "collapsed" state
transform: translateX(calc(min(100vw - $minWidth, $mainWidth) - max($minWidth, $mainWidth)));
box-shadow: 2em 0 2em 2em rgba(0,0,0,0.7);
}

.animateSidebar #sidebar {
transition: all $sidebarAnimationDuration ease;
transition: transform $sidebarAnimationDuration ease;
}

#content {
Expand Down

0 comments on commit f4a655a

Please sign in to comment.