Skip to content

Commit 4009f4d

Browse files
RivaIvanovaSisIvanovasimeonoff
authored
feat(carousel): align with WC carousel (#14651)
* feat(carousel): add vertical & indicator props; add keyboard focus classes --------- Co-authored-by: sivanova <[email protected]> Co-authored-by: Silvia Ivanova <[email protected]> Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent d90f194 commit 4009f4d

21 files changed

+764
-196
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes for each version of this project will be documented in this
99
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
1010
- To streamline the sorting of columns with custom formats, a new `FormattedValuesSortingStrategy` has been introduced. This strategy simplifies the sorting process by allowing direct sorting based on formatted values, eliminating the need to extend the `DefaultSortingStrategy` or implement a custom `ISortingStrategy`. This enhancement improves the ease of handling sorting with custom column formatters.
1111

12+
- `IgxCarousel`
13+
- Added support for vertical alignment. Can be configured via the `vertical` property. Defaults to `false`.
14+
- Added support for showing/hiding the indicator controls (dots). Can be configured via the `indicators` property. Defaults to `true`.
15+
1216
#### Scrollbar: New CSS variables
1317

1418
We have introduced new CSS variables to allow for more customizable scrollbars. This enhancement utilizes the available WebKit pseudo-selectors such as `::-webkit-scrollbar-track`. However, please note that these pseudo-selectors are prefixed with `-webkit-` and are only supported in WebKit-based browsers (e.g., Chrome, Safari).
@@ -34,6 +38,12 @@ For Firefox users, we provide limited scrollbar styling options through the foll
3438
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`, `IgxPivotGrid`
3539
- **Deprecation** The `shouldGenerate` property has been deprecated and will be removed in a future version. Column re-creation now relies on `autoGenerate` instead. Automatic migration to this is available and will be applied on `ng update`. Note that if `autoGenerate` is already set initially, there is no need to explicitly set it elsewhere in your code.
3640

41+
- `IgxCarousel`
42+
- `animationType` input property is now of type `CarouselAnimationType`. `HorizontalAnimationType` can also be used, however, to accommodate the new vertical mode, which supports vertical slide animations, it is recommended to use `CarouselAnimationType`.
43+
44+
- **Behavioral Changes** - the `keyboardSupport` input property now defaults to `false`.
45+
- **Deprecation** - the `keyboardSupport` input property has been deprecated and will be removed in a future version. Keyboard navigation with `ArrowLeft`, `ArrowRight`, `Home`, and `End` keys will be supported when focusing the indicators' container via ` Tab`/`Shift+Tab`.
46+
3747
## 18.1.0
3848
### New Features
3949
- `IgxPivotGrid`
@@ -4620,4 +4630,3 @@ export class IgxCustomFilteringOperand extends IgxFilteringOperand {
46204630
- `IgxDraggableDirective` moved inside `../directives/dragdrop/` folder
46214631
- `IgxRippleDirective` moved inside `../directives/ripple/` folder
46224632
- Folder `"./navigation/nav-service"` renamed to `"./navigation/nav.service"`
4623-

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@types/source-map": "0.5.2",
7575
"express": "^4.21.0",
7676
"fflate": "^0.8.1",
77-
"igniteui-theming": "^12.2.1",
77+
"igniteui-theming": "^13.0.0",
7878
"igniteui-trial-watermark": "^3.0.2",
7979
"lodash-es": "^4.17.21",
8080
"rxjs": "^7.8.0",

projects/igniteui-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"igniteui-trial-watermark": "^3.0.2",
7575
"lodash-es": "^4.17.21",
7676
"uuid": "^9.0.0",
77-
"igniteui-theming": "^12.2.1",
77+
"igniteui-theming": "^13.0.0",
7878
"@igniteui/material-icons-extended": "^3.0.0"
7979
},
8080
"peerDependencies": {

projects/igniteui-angular/src/lib/carousel/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ A walkthrough of how to get started can be found [here](https://www.infragistics
1313
| `pause` | boolean | Should the carousel stop playing on user interaction. Defaults to `true`. |
1414
| `interval` | number | The amount of time in milliseconds between slides transition. |
1515
| `navigation` | boolean | Controls should the carousel render the left/right navigation buttons. Defaults to `true`. |
16-
| `keyboardSupport` | boolean | Controls should the keyboard navigation should be supported. Defaults to `true`. |
16+
| `indicators` | boolean | Controls should the carousel render the indicators. Defaults to `true`. |
17+
| `vertical` | boolean | Controls should the carousel be rendered in vertical alignment. Defaults to `false`. |
18+
| `keyboardSupport` | boolean | Controls should the keyboard navigation should be supported. Defaults to `false`. |
1719
| `gesturesSupport` | boolean | Controls should the gestures should be supported. Defaults to `true`. |
1820
| `maximumIndicatorsCount` | number | The number of visible indicators. Defaults to `5`. |
1921
| `indicatorsOrientation` | CarouselIndicatorsOrientation | Controls whether the indicators should be previewed on top or on bottom of carousel. Defaults to `bottom`. |
20-
| `animationType` | HorizontalAnimationType | Controls what animation should be played when slides are changing. Defaults to `slide`. |
22+
| `animationType` | CarouselAnimationType | Controls what animation should be played when slides are changing. Defaults to `slide`. |
2123
| `total` | number | The number of slides the carousel currently has. |
2224
| `current` | number | The index of the slide currently showing. |
2325
| `isPlaying` | boolean | Returns whether the carousel is paused/playing. |

projects/igniteui-angular/src/lib/carousel/carousel-base.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChangeDetectorRef, EventEmitter, Inject } from '@angular/core';
33
import { IgxAngularAnimationService } from '../services/animation/angular-animation-service';
44
import { AnimationPlayer, AnimationService } from '../services/animation/animation';
55
import { fadeIn, slideInLeft } from 'igniteui-angular/animations';
6-
import { HorizontalAnimationType } from './enums';
6+
import { CarouselAnimationType } from './enums';
77

88
export enum Direction { NONE, NEXT, PREV }
99

@@ -21,7 +21,7 @@ export interface IgxSlideComponentBase {
2121
/** @hidden */
2222
export abstract class IgxCarouselComponentBase {
2323
/** @hidden */
24-
public animationType: HorizontalAnimationType = HorizontalAnimationType.slide;
24+
public animationType: CarouselAnimationType = CarouselAnimationType.slide;
2525

2626
/** @hidden @internal */
2727
public enterAnimationDone = new EventEmitter();
@@ -42,6 +42,8 @@ export abstract class IgxCarouselComponentBase {
4242
protected animationPosition = 0;
4343
/** @hidden */
4444
protected newDuration = 0;
45+
/** @hidden */
46+
protected vertical = false;
4547

4648
constructor(
4749
@Inject(IgxAngularAnimationService) private animationService: AnimationService,
@@ -50,7 +52,7 @@ export abstract class IgxCarouselComponentBase {
5052

5153
/** @hidden */
5254
protected triggerAnimations() {
53-
if (this.animationType !== HorizontalAnimationType.none) {
55+
if (this.animationType !== CarouselAnimationType.none) {
5456
if (this.animationStarted(this.leaveAnimationPlayer) || this.animationStarted(this.enterAnimationPlayer)) {
5557
requestAnimationFrame(() => {
5658
this.resetAnimations();
@@ -96,7 +98,7 @@ export abstract class IgxCarouselComponentBase {
9698

9799
const trans = this.animationPosition ? this.animationPosition * 100 : 100;
98100
switch (this.animationType) {
99-
case HorizontalAnimationType.slide:
101+
case CarouselAnimationType.slide:
100102
return {
101103
enterAnimation: useAnimation(slideInLeft,
102104
{
@@ -105,8 +107,8 @@ export abstract class IgxCarouselComponentBase {
105107
duration: `${duration}ms`,
106108
endOpacity: 1,
107109
startOpacity: 1,
108-
fromPosition: `translateX(${this.currentItem.direction === 1 ? trans : -trans}%)`,
109-
toPosition: 'translateX(0%)'
110+
fromPosition: `${this.vertical ? 'translateY' : 'translateX'}(${this.currentItem.direction === 1 ? trans : -trans}%)`,
111+
toPosition: `${this.vertical ? 'translateY(0%)' : 'translateX(0%)'}`
110112
}
111113
}),
112114
leaveAnimation: useAnimation(slideInLeft,
@@ -116,12 +118,12 @@ export abstract class IgxCarouselComponentBase {
116118
duration: `${duration}ms`,
117119
endOpacity: 1,
118120
startOpacity: 1,
119-
fromPosition: `translateX(0%)`,
120-
toPosition: `translateX(${this.currentItem.direction === 1 ? -trans : trans}%)`,
121+
fromPosition: `${this.vertical ? 'translateY(0%)' : 'translateX(0%)'}`,
122+
toPosition: `${this.vertical ? 'translateY' : 'translateX'}(${this.currentItem.direction === 1 ? -trans : trans}%)`,
121123
}
122124
})
123125
};
124-
case HorizontalAnimationType.fade:
126+
case CarouselAnimationType.fade:
125127
return {
126128
enterAnimation: useAnimation(fadeIn,
127129
{ params: { duration: `${duration}ms`, startOpacity: `${this.animationPosition}` } }),

projects/igniteui-angular/src/lib/carousel/carousel.component.html

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,56 @@
44
</div>
55
</ng-template>
66

7-
<ng-template #defaultNextButton let-disabled>
8-
<span class="igx-nav-arrow"
9-
[class.igx-nav-arrow--disabled]="disabled">
10-
<igx-icon aria-hidden="true" family="default" name="carousel_next"></igx-icon>
11-
</span>
7+
<ng-template #defaultNextButton>
8+
<igx-icon aria-hidden="true" family="default" name="carousel_next"
9+
class="igx-nav-arrow">
10+
</igx-icon>
1211
</ng-template>
1312

14-
<ng-template #defaultPrevButton let-disabled>
15-
<span class="igx-nav-arrow"
16-
[class.igx-nav-arrow--disabled]="disabled">
17-
<igx-icon aria-hidden="true" family="default" name="carousel_prev"></igx-icon>
18-
</span>
13+
<ng-template #defaultPrevButton>
14+
<igx-icon aria-hidden="true" family="default" name="carousel_prev"
15+
class="igx-nav-arrow">
16+
</igx-icon>
1917
</ng-template>
2018

21-
<div *ngIf="showIndicators" [ngClass]="indicatorsOrientationClass" [attr.role]="'tablist'">
22-
<div *ngFor="let slide of slides"
19+
<button *ngIf="navigation && slides.length"
20+
igxButton
21+
class="igx-carousel__arrow--prev"
22+
[attr.aria-label]="resourceStrings.igx_carousel_previous_slide"
23+
[disabled]="prevButtonDisabled"
24+
(click)="prev()"
25+
(keydown)="handleKeydownPrev($event)">
26+
<ng-container *ngTemplateOutlet="getPrevButtonTemplate; context: {$implicit: prevButtonDisabled};"></ng-container>
27+
</button>
28+
29+
<button *ngIf="navigation && slides.length"
30+
igxButton
31+
class="igx-carousel__arrow--next"
32+
[attr.aria-label]="resourceStrings.igx_carousel_next_slide"
33+
[disabled]="nextButtonDisabled"
34+
(click)="next()"
35+
(keydown)="handleKeydownNext($event)">
36+
<ng-container *ngTemplateOutlet="getNextButtonTemplate; context: {$implicit: nextButtonDisabled};"></ng-container>
37+
</button>
38+
39+
<div *ngIf="showIndicators" [ngClass]="indicatorsClass" [attr.role]="'tablist'" (keyup)="handleKeyUp($event)" (focusout)="handleFocusOut($event)" (click)="handleClick()" (keydown)="handleKeydown($event)">
40+
<div #indicators *ngFor="let slide of slides"
2341
class="igx-carousel-indicators__indicator"
2442
(click)="select(slide)"
2543
[id]="'tab-'+ slide.index + '-' + total"
2644
[attr.role]="'tab'"
45+
[attr.tabindex]="slide.active ? 0 : -1"
2746
[attr.aria-label]="resourceStrings.igx_carousel_slide + ' ' + (slide.index + 1) + ' ' + resourceStrings.igx_carousel_of + ' ' + this.total"
2847
[attr.aria-controls]="'panel-' + slide.index"
2948
[attr.aria-selected]="slide.active">
3049
<ng-container *ngTemplateOutlet="getIndicatorTemplate; context: {$implicit: slide};"></ng-container>
3150
</div>
3251
</div>
3352

34-
<div *ngIf="showIndicatorsLabel" [ngClass]="indicatorsOrientationClass">
53+
<div *ngIf="showIndicatorsLabel" [ngClass]="indicatorsClass" class="igx-carousel-label-indicator">
3554
<span [id]="labelId" class="igx-carousel__label">{{getCarouselLabel}}</span>
3655
</div>
3756

3857
<div class="igx-carousel__inner" [attr.aria-live]="!interval || stoppedByInteraction ? 'polite' : 'off'">
3958
<ng-content></ng-content>
4059
</div>
41-
42-
<div *ngIf="navigation && slides.length" role="button" tabindex="0" class="igx-carousel__arrow--prev" [attr.aria-label]="resourceStrings.igx_carousel_previous_slide" (keydown.enter)="prev()" (click)="prev()">
43-
<ng-container *ngTemplateOutlet="getPrevButtonTemplate; context: {$implicit: prevButtonDisabled};"></ng-container>
44-
</div>
45-
46-
<div *ngIf="navigation && slides.length" role="button" tabindex="0" class="igx-carousel__arrow--next" [attr.aria-label]="resourceStrings.igx_carousel_next_slide" (keydown.enter)="next()" (click)="next()">
47-
<ng-container *ngTemplateOutlet="getNextButtonTemplate; context: {$implicit: nextButtonDisabled};"></ng-container>
48-
</div>

0 commit comments

Comments
 (0)