Skip to content

Commit

Permalink
Replace jQuery show animation with CSS animation in sidebar
Browse files Browse the repository at this point in the history
The sidebar-showing animation was relying on jQuery, which just animates
the width/height properties (absolutely killer for performance). Replace
this with a CSS animation. Note, the animation isn't identical;
previously the document size would animate, but this now just snaps to
the destination size. Animating document size changes is unlikely to be
viable any time soon, but we may want to consider some kind of 2-part
move + resize animation.

Signed-off-by: Chris Lord <[email protected]>
Change-Id: I68eb16e9eff9a3a9601f3f903f9edb25b97a56cd
  • Loading branch information
Chris Lord committed Jan 30, 2025
1 parent cbc6636 commit f669d30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 15 additions & 0 deletions browser/css/cool.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,21 @@ body {
overflow: hidden;
z-index: 990;
}

#sidebar-dock-wrapper.visible {
display: block;
animation: 200ms ease-out appear-from-right;
}

@keyframes appear-from-right {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}

#sidebar-panel {
padding: 0px;
margin: 0px;
Expand Down
7 changes: 3 additions & 4 deletions browser/src/control/Control.Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class Sidebar {
}

isVisible(): boolean {
return $('#sidebar-dock-wrapper').is(':visible');
return $('#sidebar-dock-wrapper').hasClass('visible');
}

closeSidebar() {
$('#sidebar-dock-wrapper').hide();
$('#sidebar-dock-wrapper').removeClass('visible');
this.map._onResize();

if (!this.map.editorHasFocus()) {
Expand Down Expand Up @@ -236,8 +236,7 @@ class Sidebar {
}

this.builder.build(this.container, [sidebarData]);
if (!this.isVisible())
$('#sidebar-dock-wrapper').show(this.options.animSpeed);
if (!this.isVisible()) $('#sidebar-dock-wrapper').addClass('visible');

this.map.uiManager.setDocTypePref('ShowSidebar', true);
} else {
Expand Down

0 comments on commit f669d30

Please sign in to comment.