Skip to content

fix(ui5-carousel): fix navigation animation#13762

Open
TeodorTaushanov wants to merge 2 commits into
mainfrom
carousel_navigate_to
Open

fix(ui5-carousel): fix navigation animation#13762
TeodorTaushanov wants to merge 2 commits into
mainfrom
carousel_navigate_to

Conversation

@TeodorTaushanov

Copy link
Copy Markdown
Member

fixes #13625

@sap-ui5-webcomponents-release

Copy link
Copy Markdown

@TeodorTaushanov TeodorTaushanov requested a review from a team July 2, 2026 10:34
});

btnNavigate.addEventListener("click", function() {
carousel._onResize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can u replace carousel._onResize(); with something public, like setting the changing the width through CSS?

Comment on lines 400 to 415
_onResize() {
const previousItemsPerPage = this.effectiveItemsPerPage;

// Set the resizing flag to suppress animation while resizing
this._resizing = true;

// Change transitively effectiveItemsPerPage by modifying _width
this._width = this.offsetWidth;
this._itemWidth = Math.floor(this._width / this.effectiveItemsPerPage);

// Items per page did not change,
// therefore page index does not need to be re-adjusted
if (this.effectiveItemsPerPage === previousItemsPerPage) {
this._updateVisibleItems(this._currentPageIndex);
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_onResize() {
		const previousItemsPerPage = this.effectiveItemsPerPage;

		// Set the resizing flag to suppress animation while resizing
		const previousWidth = this._width;

		this._resizing = true;

		// Change transitively effectiveItemsPerPage by modifying _width
		this._width = this.offsetWidth;
		this._itemWidth = Math.floor(this._width / this.effectiveItemsPerPage);

		// Items per page did not change,
		// therefore page index does not need to be re-adjusted
		if (this._width === previousWidth && this.effectiveItemsPerPage === previousItemsPerPage) {
			this._resizing = false;
			this._updateVisibleItems(this._currentPageIndex);
			return;
		}

return;
}

this._resizing = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep _changePageIndex clean, without this side effect, I proposed another handling in _onResize

cy.get<Carousel>("#carousel")
.then($carousel => {
const carousel = $carousel[0];
carousel._onResize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to change the width of the carousel via CSS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Carousel: Carousel.navigateTo() doesn't reset _resizing flag, causing first programmatic navigation to have no animation

2 participants