Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component: Carousel | Circular Option is broken when first iteration is done #13821

Closed
EnricoMessall opened this issue Oct 7, 2023 · 3 comments · Fixed by #13824
Closed

Component: Carousel | Circular Option is broken when first iteration is done #13821

EnricoMessall opened this issue Oct 7, 2023 · 3 comments · Fixed by #13824
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@EnricoMessall
Copy link
Contributor

EnricoMessall commented Oct 7, 2023

Describe the bug

When first circular iteration is done, the component moves back all the way to the second element see:
https://www.youtube.com/watch?v=9YeLum9tyn0

Looking into some console loggings, it is looking for me that the value at position 7 to -3 (totalShiftedItems) is being wrongly overwritten by the second logging at position 4 to -1 (totalShiftedItems).

The second logging in this case is the ngAfterContentChecked function.

Screenshot 2023-10-07 at 08 26 05

Environment

Reproducer

https://primeng.org/carousel

Angular version

16.2.3

PrimeNG version

16.4.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.5.1

Browser(s)

Chrome, Safari

Steps to reproduce the behavior

No response

Expected behavior

No response

@EnricoMessall EnricoMessall added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 7, 2023
@EnricoMessall
Copy link
Contributor Author

EnricoMessall commented Oct 7, 2023

Problem is part of the totalShiftedItems.

It lays in onTransitionEnd where the first element is getting a translate3d of 100 after first of all having one of 1100 after some milliseconds. If the carousel isn't waiting for that, this effect happens.

@EnricoMessall
Copy link
Contributor Author

Results from ngAfterContentChecked this line. When using normal stepping by hand this line resets totalShiftedItems to its correct value before calling onTransitionEnd. With autoplayInterval or too fast clicking ngAfterContentChecked happens after onTransitionEnd and results in having the wrong translate3d value

@notetosiraj
Copy link

modified totalShiftedItems condition seems issue may fixed .

`
//carousel.ts

step(dir: number, page?: number) {

// code removed here due to brevity

if (isCircular && this.page === this.totalDots() - 1 && dir === -1)
{
totalShiftedItems = -1 * this._numVisible; // modified line
page = 0;
}

}
`
gitissue

@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 26, 2023
@cetincakiroglu cetincakiroglu added this to the 16.6.0 milestone Oct 26, 2023
cetincakiroglu added a commit that referenced this issue Oct 26, 2023
Fixed #13821 - Fixed carousel autoplay + circular problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants