Skip to content

Commit

Permalink
* sidebar: fix animation not work as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Apr 16, 2024
1 parent 9b14299 commit 262f7cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/sidebar/src/style/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@apply -hidden;
}
.sidebar.is-collapsed > .sidebar-gutter {
@apply -flex;
@apply !-flex;
}

.sidebar-gutter {
Expand Down
8 changes: 6 additions & 2 deletions lib/sidebar/src/vanilla/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Sidebar extends Component<SidebarOptions, {
this._$gutter = $gutter;

this.render();
$element.css({'--gutter-width': `${gutterWidth}px`, width: `var(--sidebar-${side}-width)`, '--sidebar-duration': typeof animation === 'number' ? `${animation}ms` : undefined});
$element.css({'--gutter-width': `${gutterWidth}px`, width: `var(--sidebar-${side}-width)`, '--sidebar-duration': typeof animation === 'number' ? `${animation}ms` : null});

if (toggleBtn) {
$gutter.append(`<button class="gutter-toggle" type="button"><span class="chevron-${side}"></span></button>`);
Expand Down Expand Up @@ -144,7 +144,11 @@ export class Sidebar extends Component<SidebarOptions, {
});
}
if (animation) {
this.on('transitionend', (e) => {if (e.target === $element[0] && e.propertyName === 'width') $element.removeClass(TRANSITION_CLASS);});
this.on('transitionend', (e) => {
if (e.target === $element[0] && e.propertyName === 'width') {
$element.removeClass(TRANSITION_CLASS);
}
});
this._raf = requestAnimationFrame(() => {
$parent.addClass(ANIMATION_CLASS);
});
Expand Down

0 comments on commit 262f7cd

Please sign in to comment.