diff --git a/packages/main/cypress/specs/Carousel.cy.tsx b/packages/main/cypress/specs/Carousel.cy.tsx index a39cadd1227c..0da32a428d9b 100644 --- a/packages/main/cypress/specs/Carousel.cy.tsx +++ b/packages/main/cypress/specs/Carousel.cy.tsx @@ -389,6 +389,32 @@ describe("Carousel general interaction", () => { }); + it.only("navigateTo method and visibleItemsIndices", () => { + cy.mount( + + + + + + + + + + + + ); + + cy.get("#carousel9") + .invoke("prop", "visibleItemsIndices") + .should("deep.equal", [0, 1]); + + cy.get("#carousel9").shadow().find('[data-ui5-arrow-forward="true"]').realClick(); + + cy.get("#carousel9") + .invoke("prop", "visibleItemsIndices") + .should("deep.equal", [1, 2]); + }); + it("F7 keyboard navigation", () => { cy.mount( diff --git a/packages/main/src/Carousel.ts b/packages/main/src/Carousel.ts index a8826f0d1b69..84e0b3a2b994 100644 --- a/packages/main/src/Carousel.ts +++ b/packages/main/src/Carousel.ts @@ -184,17 +184,6 @@ class Carousel extends UI5Element { @property({ type: Boolean }) hideNavigationArrows = false; - /** - * Defines the current first visible item in the viewport. - * Default value is 0, which means the first item in the viewport. - * - * @since 1.0.0-rc.15 - * @default 0 - * @public - */ - @property({ type: Number, noAttribute: true }) - _currentSlideIndex: number = 0; - /** * Defines the visibility of the page indicator. * If set to true the page indicator will be hidden. @@ -288,6 +277,14 @@ class Carousel extends UI5Element { @property({ type: Boolean, noAttribute: true }) _visibleNavigationArrows = false; + /** + * Defines the current slide index, which contains the visible item in the viewport. + * @private + * @since 2.16.0-r.c1 + */ + @property({ type: Number, noAttribute: true }) + _currentSlideIndex: number = 0; + _scrollEnablement: ScrollEnablement; _onResizeBound: ResizeObserverCallback; _resizing: boolean; @@ -700,6 +697,16 @@ class Carousel extends UI5Element { this.focusItem(); } + /** + * The indices of the currently visible items of the component. + * @public + * @since 1.0.0-rc.15 + * @default [] + */ + get visibleItemsIndices() : Array { + return this._visibleItemsIndexes; + } + /** * Assuming that all items have the same width * @private