Skip to content

Commit 2adee01

Browse files
authored
fix(ui5-carousel): implement hideNavigationArrows property (#3228)
Implements hideNavigationArrows property. In relation to #3107 BREAKING_CHANGE: hideNavigation property of ui5-carousel is deprecated in favour of hideNavigationArrows. The new property shows/hides the arrows only(not both the arrows and the dots in the bottom)
1 parent 49639e5 commit 2adee01

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/main/src/Carousel.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
{{/if}}
3232

33-
{{#if showNavigation}}
33+
{{#if hasManyPages}}
3434
<div class="{{classes.navigation}}">
3535
{{#if arrows.navigation}}
3636
{{> arrow-back}}

packages/main/src/Carousel.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ const metadata = {
8686
/**
8787
* If set to true the navigation is hidden.
8888
* @type {boolean}
89+
* @since 1.0.0-rc.15
8990
* @defaultvalue false
9091
* @public
9192
*/
92-
hideNavigation: {
93+
hideNavigationArrows: {
9394
type: Boolean,
9495
},
9596

@@ -434,6 +435,10 @@ class Carousel extends UI5Element {
434435
return index >= 0 && index <= this.pagesCount - 1;
435436
}
436437

438+
get hasManyPages() {
439+
return this.pagesCount > 1;
440+
}
441+
437442
get styles() {
438443
return {
439444
content: {
@@ -450,12 +455,12 @@ class Carousel extends UI5Element {
450455
content: {
451456
"ui5-carousel-content": true,
452457
"ui5-carousel-content-no-animation": this.supressAimation,
453-
"ui5-carousel-content-has-navigation": this.showNavigation,
454-
"ui5-carousel-content-has-navigation-and-buttons": this.showNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
458+
"ui5-carousel-content-has-navigation": this.hasManyPages,
459+
"ui5-carousel-content-has-navigation-and-buttons": this.hasManyPages && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
455460
},
456461
navigation: {
457462
"ui5-carousel-navigation-wrapper": true,
458-
"ui5-carousel-navigation-with-buttons": this.showNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
463+
"ui5-carousel-navigation-with-buttons": this.hasManyPages && (this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows),
459464
},
460465
navPrevButton: {
461466
"ui5-carousel-navigation-button--hidden": !this.hasPrev,
@@ -490,11 +495,11 @@ class Carousel extends UI5Element {
490495
}
491496

492497
get arrows() {
493-
const showArrows = this._visibleNavigationArrows && this.showNavigation && isDesktop();
498+
const showArrows = this._visibleNavigationArrows && this.hasManyPages && isDesktop();
494499

495500
return {
496-
content: showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Content,
497-
navigation: showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
501+
content: !this.hideNavigationArrows && showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Content,
502+
navigation: !this.hideNavigationArrows && showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
498503
};
499504
}
500505

@@ -518,10 +523,6 @@ class Carousel extends UI5Element {
518523
return this._isRTL ? this.pagesCount - (this.pagesCount - this.selectedIndex) + 1 : this.selectedIndex + 1;
519524
}
520525

521-
get showNavigation() {
522-
return !this.hideNavigation && this.pagesCount > 1;
523-
}
524-
525526
get ofText() {
526527
return this.i18nBundle.getText(CAROUSEL_OF_TEXT);
527528
}

0 commit comments

Comments
 (0)