Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/main/cypress/specs/Carousel.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,32 @@ describe("Carousel general interaction", () => {

});

it.only("navigateTo method and visibleItemsIndices", () => {
cy.mount(
<Carousel id="carousel9" itemsPerPage="S1 M2 L2 XL2" arrowsPlacement="Navigation">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button>Button 4</Button>
<Button>Button 5</Button>
<Button>Button 6</Button>
<Button>Button 7</Button>
<Button>Button 8</Button>
<Button>Button 9</Button>
<Button>Button 10</Button>
</Carousel>);

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(
<Carousel id="carouselF7" itemsPerPage="S3 M3 L3 XL3">
Expand Down
29 changes: 18 additions & 11 deletions packages/main/src/Carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<number> {
return this._visibleItemsIndexes;
}

/**
* Assuming that all items have the same width
* @private
Expand Down
Loading