Skip to content

Commit d7c938a

Browse files
authored
feat(tab-bar): Add a mixin to set scroller animation (material-components#5172)
1 parent efda83d commit d7c938a

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

packages/mdc-tab-bar/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Mixin | Description
107107
`mdc-tab-bar-width($width)` | Customizes the width of the tab bar.
108108
`mdc-tab-bar-density($density-scale)` | Sets density scale to default tab bar variant. Use `mdc-tab-bar-stacked-density` mixin for stacked variant. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
109109
`mdc-tab-bar-stacked-density($density-scale)` | Sets density scale to stacked tab bar variant. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
110+
`mdc-tab-bar-tab-scroller-transition($duration-ms, $timing-function)` | Sets the CSS transition for the tab scrolling animation. This mixin is a proxy to `mdc-tab-scroller-transition` mixin.
110111

111112

112113
## `MDCTabBar` Properties and Methods

packages/mdc-tab-bar/_mixins.scss

+19
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
// THE SOFTWARE.
2121
//
2222

23+
@import "@material/animation/variables";
2324
@import "@material/density/functions";
2425
@import "@material/feature-targeting/functions";
2526
@import "@material/feature-targeting/mixins";
27+
@import "@material/tab-scroller/mixins";
2628
@import "@material/tab/mixins";
2729
@import "./variables";
2830

@@ -79,3 +81,20 @@
7981
@include mdc-tab-height($height, $query: $query);
8082
}
8183
}
84+
85+
///
86+
/// Sets the CSS transition for the tab scrolling animation. This mixin is a proxy to `mdc-tab-scroller-transition`
87+
/// mixin.
88+
///
89+
/// @param {Number | String} $duration-ms - Duration (in ms) of the animation.
90+
/// @param {String} $timing-function - Optionally overrides the default animation timing function.
91+
///
92+
@mixin mdc-tab-bar-tab-scroller-transition(
93+
$duration-ms,
94+
$timing-function: $mdc-animation-standard-curve-timing-function,
95+
$query: mdc-feature-all()
96+
) {
97+
.mdc-tab-scroller {
98+
@include mdc-tab-scroller-transition($duration-ms, $timing-function: $timing-function, $query: $query);
99+
}
100+
}

packages/mdc-tab-bar/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"directory": "packages/mdc-tab-bar"
2020
},
2121
"dependencies": {
22+
"@material/animation": "^3.1.0",
2223
"@material/base": "^3.1.0",
2324
"@material/density": "^0.0.0",
2425
"@material/elevation": "^3.1.0",

test/scss/_feature-targeting-test.scss

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@
298298
@include mdc-tab-height(0, $query: $query);
299299
@include mdc-tab-bar-density(0, $query: $query);
300300
@include mdc-tab-bar-stacked-density(0, $query: $query);
301+
@include mdc-tab-bar-tab-scroller-transition(0, $query: $query);
301302

302303
// Theme
303304
@include mdc-theme-core-styles($query: $query);

0 commit comments

Comments
 (0)