Skip to content

Commit

Permalink
Merge pull request #8255 from IgniteUI/valadzhov/tab-nav-drawer-anima…
Browse files Browse the repository at this point in the history
…tion-7157

feat(tab-nav-drawer, tabs): Disable animation. #7157
  • Loading branch information
Lipata authored Oct 7, 2020
2 parents 8df3307 + 9a5ffd6 commit 3b24fbc
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All notable changes for each version of this project will be documented in this
- **Breaking Change** - Deprecated the `label` property.
- `igxGridActions`
- Added `asMenuItems` Input for grid actions - `igx-grid-editing-actions`, `igx-grid-pinning-actions`. When set to true will render the related action buttons as separate menu items with button and label.
- `igxNavigationDrawer`
- Added `disableAnimation` property which enables/disables the animation, when toggling the drawer. Set to `false` by default.
- `igxTabs`
- Added `disableAnimation` property which enables/disables the transition animation of the tabs' content. Set to `false` by default.
- `IgxExpansionPanel`
- `IExpansionPanelEventArgs.panel` - Deprecated. Usе `owner` property to get a reference to the panel.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@
@include e(item, header) {
@extend %item--header !optional;
}

@include m(disable-animation) {
@extend %disable-animation !optional;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@
transition: none;
visibility: hidden;
}

%disable-animation {
transition-duration: 0s;
}
}

/// Adds typography styles for the igx-navdrawer component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The navigation drawer can either sit above content or be pinned alongside it and
| `pinThreshold` | number | Minimum device width required for automatic pin to be toggled. Default is 1024, can be set to a falsy value to disable this behavior. |
| `width` | string| Width of the drawer in its open state. Defaults to "280px".|
| `miniWidth` | string | Width of the drawer in its mini variant. Defaults to "60px". |
| `disableAnimation` | boolean | Enables/disables the animation, when toggling the drawer. Set to `false` by default.

### Outputs
| Name | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div [hidden]="pin"
class="igx-nav-drawer__overlay"
[class.igx-nav-drawer__overlay--hidden]="!isOpen"
[class.igx-nav-drawer--disable-animation]="disableAnimation"
(click)="close()" #overlay>
</div>
<aside role="navigation"
Expand All @@ -18,7 +19,8 @@
[class.igx-nav-drawer__aside--mini]="miniTemplate && !isOpen"
[class.igx-nav-drawer__aside--normal]="!miniTemplate || isOpen"
[class.igx-nav-drawer__aside--pinned]="pin"
[class.igx-nav-drawer__aside--right]="position == 'right'" #aside>
[class.igx-nav-drawer__aside--right]="position == 'right'" #aside
[class.igx-nav-drawer--disable-animation]="disableAnimation">

<ng-container *ngTemplateOutlet="template || defaultItemsTemplate"></ng-container>
</aside>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ export class IgxNavigationDrawerComponent implements
*/
@Input() public width = '280px';


/**
* Enables/disables the animation, when toggling the drawer. Set to `false` by default.
* ````html
* <igx-nav-drawer [disableAnimation]="true"></igx-nav-drawer>
* ````
*/
@HostBinding ('class.igx-nav-drawer--disable-animation')
@Input() public disableAnimation = false;

/**
* Width of the drawer in its mini state. Defaults to 68px.
*
Expand Down
1 change: 1 addition & 0 deletions projects/igniteui-angular/src/lib/tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ If the total visible items width exceeds the vew port width, scroll buttons are
| `label` | string | Set the tab item text. |
| `disabled` | boolean | Set if the tab is enabled/disabled. |
| `type` | IgxTabsType | Set the tab item sizing mode. By default, `contentfit` is set, the tab item width is sized to its content in the range of min/max width. When the sizing type is `fixed` - all tabs have equal size to fit the view port. |
| `disableAnimation`| boolean | Enables/disables the transition animation of the tabs' content. Set to `false` by default.

## Events

Expand Down
11 changes: 10 additions & 1 deletion projects/igniteui-angular/src/lib/tabs/tabs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ export class IgxTabsComponent implements IgxTabsBase, AfterViewInit, OnDestroy {
*/
public visibleItemsWidth: number;

/**
* Enables/disables the transition animation of the tabs' content. Set to `false` by default.
* ````html
* <igx-tabs [disableAnimation]="true"></igx-tabs>
*/
@Input()
public disableAnimation = false;

/**
* @hidden
*/
Expand Down Expand Up @@ -462,13 +470,14 @@ export class IgxTabsComponent implements IgxTabsBase, AfterViewInit, OnDestroy {
this.onTabItemSelected.emit({ tab: newTab, group: newTabRelatedGroup });

requestAnimationFrame(() => {
const transitionDuration = this.disableAnimation ? 0 : 0.2;
// bring the new selected tab into view if it is not
this.bringNewTabIntoView(newTab);
// animate the new selection indicator
this.transformIndicatorAnimation(newTab.nativeTabItem.nativeElement);
// animate the new tab's group content
if (!this.hasContentTabs) {
this.transformContentAnimation(newTab, 0.2);
this.transformContentAnimation(newTab, transitionDuration);
}
});
}
Expand Down

0 comments on commit 3b24fbc

Please sign in to comment.