Skip to content

Commit

Permalink
fixed #7081 - laggy tab open/close animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Nov 1, 2022
1 parent 8d10bc1 commit 856c042
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion tabby-core/src/components/appRoot.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ title-bar(
[index]='idx',
[tab]='tab',
[active]='tab == app.activeTab',
@animateTab,
[@animateTab]='{value: "in", params: {size: targetTabSize}}',
[@.disabled]='hasVerticalTabs() || !config.store.accessibility.animations',
(click)='app.selectTab(tab)',
[class.fully-draggable]='hostApp.platform != Platform.macOS',
Expand Down
68 changes: 42 additions & 26 deletions tabby-core/src/components/appRoot.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,47 @@ import { TabBodyComponent } from './tabBody.component'
import { SplitTabComponent } from './splitTab.component'
import { AppService, FileTransfer, HostWindowService, PlatformService, ToolbarButton, ToolbarButtonProvider } from '../api'

function makeTabAnimation (dimension: string, size: number) {
return [
state('in', style({
'flex-basis': '{{size}}',
[dimension]: '{{size}}',
}), {
params: { size: `${size}px` },
}),
transition(':enter', [
style({
'flex-basis': '1px',
[dimension]: '1px',
}),
animate('250ms ease-out', style({
'flex-basis': '{{size}}',
[dimension]: '{{size}}',
})),
]),
transition(':leave', [
style({
'flex-basis': 'auto',
'padding-left': '*',
'padding-right': '*',
[dimension]: '*',
}),
animate('250ms ease-in-out', style({
'padding-left': 0,
'padding-right': 0,
[dimension]: '0',
})),
]),
]
}

/** @hidden */
@Component({
selector: 'app-root',
template: require('./appRoot.component.pug'),
styles: [require('./appRoot.component.scss')],
animations: [
trigger('animateTab', [
state('in', style({
'flex-basis': 'auto',
width: 'auto',
})),
transition(':enter', [
style({
'flex-basis': '1px',
width: '1px',
}),
animate('250ms ease-in-out', style({
'flex-basis': 'auto',
width: 'auto',
})),
]),
transition(':leave', [
style({
'flex-basis': 'auto',
width: 'auto',
}),
animate('250ms ease-in-out', style({
'flex-basis': '1px',
width: '1px',
})),
]),
]),
trigger('animateTab', makeTabAnimation('width', 200)),
],
})
export class AppRootComponent {
Expand Down Expand Up @@ -196,6 +205,13 @@ export class AppRootComponent {
return this.config.store.appearance.tabsLocation === 'left' || this.config.store.appearance.tabsLocation === 'right'
}

get targetTabSize (): any {
if (this.hasVerticalTabs()) {
return '*'
}
return this.config.store.appearance.flexTabs ? '*' : '200px'
}

async generateButtonSubmenu (button: ToolbarButton) {
if (button.submenu) {
button.submenuItems = await button.submenu()
Expand Down
13 changes: 8 additions & 5 deletions tabby-core/src/components/tabHeader.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@ $tabs-height: 38px;
:host {
position: relative;
cursor: pointer;
box-sizing: content-box;

> * { cursor: pointer; }

flex: 1000 1 200px;
width: 200px;
padding: 0 10px;
// flex-basis and width are also set through animation on AppRoot

&.flex-width {
flex: 1000 1 auto;
width: auto;
}
padding: 0 10px;

display: flex;
flex-direction: row;
min-width: 0;

overflow: hidden;

&.flex-width {
flex: 1000 1 auto;
width: auto;
}

&.vertical {
flex: none;
height: $tabs-height;
Expand Down

0 comments on commit 856c042

Please sign in to comment.