-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(carousel): add animations #3804
feat(carousel): add animations #3804
Conversation
5e3b59e
to
c082b33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Please have a look a the couple question I left here and there in the review. Nothing big, mostly minor changes.
c082b33
to
897bb89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @fbasso!
Same as for the accordion - all carousel demos are crashing with this version
See other comments in the code direclty.
Cheers,
Max
src/carousel/carousel.ts
Outdated
(click)="select(slide.id, NgbSlideEventSource.INDICATOR)"></li> | ||
</ol> | ||
<div class="carousel-inner"> | ||
<div *ngFor="let slide of slides" class="carousel-item" [class.active]="slide.id === activeId"> | ||
<div *ngFor="let slide of slides" class="carousel-item" [id]="'ngb-slide-' + slide.id"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generates the following ids: ex. ngb-slide-ngb-slide-13
, why is the ngb-slide-
prefix necessary?
Can't we just use slide.id
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, having dom ids starting with numbers is a problem. It's just to avoid this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already prefixed with ngb-slide-
, you're prefixing it twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, I answered too quickly 😟. I think I prefixed it the same way than the the indicators, but it's not needed. I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, I need to prefix it. We prefixed the id only when it's not provided, this way:
@Input() id = `ngb-slide-${nextId++}`;
See the test should mark the requested slide as active
for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about not prefixing it when provided, but making sure they do not provide a number as ID ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, I think the simpler (what have done in the latest version) is to prefix it in the template, not in the generated id. It keeps the freedom to provide what you want, without having to check anything.
ef8f72d
to
ccfa17e
Compare
I pushed back most of the required changes. Still working on the Edit: still some issues to solve from unit tests |
827266d
to
37fabe3
Compare
Latest changes pushed. The tests fails at the moment because of a mismatch between chrome driver (support only 85) and Chrome (officially 84 at the moment). I integrated all the required changes, but maybe still things to discuss:
|
37fabe3
to
ce31dca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @fbasso!
LGTM, we just need to finish this id story :)
The way it is implemented now is a breaking change, so we should either fix it or make a proper commit comment.
if you don't want to use document.getElementById()
, what we should do is the following to avoid using DOM queries altogether ourselves:
<div class="carousel-inner">
<div #slideElements *ngFor="let slide of slides; ..." [id]="slide.id" ...>
...
</div>
</div>
@ViewChildren('slideElements') private _slideElements: QueryList<ElementRef<HTMLElement>>;
private _getSlideElement(slideId: string): HTMLElement {
return this._slideElements.find(({nativeElement}) => nativeElement.id === slideId)!.nativeElement;
}
WDYT?
Cheers,
Max
ce31dca
to
5cebf2f
Compare
After some discussion with @maxokorokov, it seems that the id are not used the way we thought. At the end, on this last change, I:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Cherry-picked form #2817, then simplified and adapted to be aligned with recent widget development.
To be noticed:
slid
event has been added (when the transition finish),