Skip to content

Commit

Permalink
feat(ui5-carousel): implement rtl support (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid authored Aug 13, 2020
1 parent 230cd7f commit f69ffa5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
58 changes: 25 additions & 33 deletions packages/main/src/Carousel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,15 @@

{{#if arrows.content}}
<div class="ui5-carousel-navigation-arrows">
<ui5-button
arrow-back
class="ui5-carousel-navigation-button {{classes.navPrevButton}}"
icon="slim-arrow-left"
tabindex="-1"
@click={{navigateLeft}}
@keydown={{_onbuttonkeydown}}
></ui5-button>
<ui5-button
arrow-forward
class="ui5-carousel-navigation-button {{classes.navNextButton}}"
icon="slim-arrow-right"
tabindex="-1"
@click={{navigateRight}}
@keydown={{_onbuttonkeydown}}
></ui5-button>
{{> arrow-back}}
{{> arrow-forward}}
</div>
{{/if}}

{{#if showNavigationArrows}}
<div class="{{classes.navigation}}">
{{#if arrows.navigation}}
<ui5-button
arrow-back
class="ui5-carousel-navigation-button {{classes.navPrevButton}}"
icon="slim-arrow-left"
tabindex="-1"
@click={{navigateLeft}}
@keydown={{_onbuttonkeydown}}
></ui5-button>
{{> arrow-back}}
{{/if}}

<div class="ui5-carousel-navigation">
Expand All @@ -71,16 +50,29 @@
</div>

{{#if arrows.navigation}}
<ui5-button
arrow-forward
class="ui5-carousel-navigation-button {{classes.navNextButton}}"
icon="slim-arrow-right"
tabindex="-1"
@click={{navigateRight}}
@keydown={{_onbuttonkeydown}}
></ui5-button>
{{> arrow-forward}}
{{/if}}
</div>
{{/if}}
</div>
</section>
</section>

{{#*inline "arrow-back"}}
<ui5-button
arrow-back
class="ui5-carousel-navigation-button {{classes.navPrevButton}}"
icon="slim-arrow-left"
tabindex="-1"
@click={{navigateLeft}}
></ui5-button>
{{/inline}}

{{#*inline "arrow-forward"}}
<ui5-button
arrow-forward
class="ui5-carousel-navigation-button {{classes.navNextButton}}"
icon="slim-arrow-right"
tabindex="-1"
@click={{navigateRight}}
></ui5-button>
{{/inline}}
8 changes: 6 additions & 2 deletions packages/main/src/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class Carousel extends UI5Element {
get styles() {
return {
content: {
transform: `translateX(-${this.selectedIndex * this._itemWidth}px`,
transform: `translateX(${this._isRTL ? "" : "-"}${this.selectedIndex * this._itemWidth}px`,
},
};
}
Expand Down Expand Up @@ -484,8 +484,12 @@ class Carousel extends UI5Element {
return this._resizing || getAnimationMode() === AnimationMode.None;
}

get _isRTL() {
return this.effectiveDir === "rtl";
}

get selectedIndexToShow() {
return this.selectedIndex + 1;
return this._isRTL ? this.pagesCount - (this.pagesCount - this.selectedIndex) + 1 : this.selectedIndex + 1;
}

get showNavigationArrows() {
Expand Down

0 comments on commit f69ffa5

Please sign in to comment.