-
Notifications
You must be signed in to change notification settings - Fork 51
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
[BUG] [UPDATE: FIXED] –– [owlRouterLink] doesn't work as intended #267
Comments
Since I got no response i have figured out a "hacky" way to solve this. Very sad and messy that i have to do this manually.
<owl-carousel-o (changed)="getData($event)" [options]="owlCarouselConfig">
<ng-container *ngFor="let item of items">
<ng-template carouselSlide>
<div (click)="onItemClick(item)" role="button">
...
</div>
</ng-template>
</ng-container>
</owl-carousel-o>
public isDragging: boolean;
// This function gets triggered whenever a drag happened,
// so update the flag always to true.
public getData($event: SlidesOutputData) {
this.isDragging = true;
}
public onItemClick(item: any) {
if (!this.isDragging) {
this._router.navigate([`/profile/${item.username}`]).then();
}
this.isDragging = false;
} No need to even use |
Edit: this hacky solution works only if the slider is not in |
BUG FIXED (hacky way)Finally I have found a hacky solution to fully fix this. The code is messy but there's no other way to do it as far as i can see unless the maintainer of this library fixes it. This is how the code needs to be set: <owl-carousel-o (dragging)="startDragging($event.dragging)" [options]="owlCarouselConfig">
<ng-container *ngFor="let item of items">
<ng-template carouselSlide>
<div (click)="onItemClick(item)" role="button">
...
</div>
</ng-template>
</ng-container>
</owl-carousel-o> public onItemClick(item: any): void {
if (!this.isDragging) {
this._router.navigate([`/profile/${item.username}`]).then();
}
this.isDragging = false;
}
public startDragging(dragging: boolean): void {
if (dragging) {
this.isDragging = true;
}
} This solution fixes the following bugs:
There were a lot of edge case scenarios similar to those examples that i encountered. Can't remember them all. But as far as i have tested this solution fixes those |
Alternate solutionFor anyone still struggling with this, i ended up switching the whole library. I replaced my carousel with Swiper Slider for angular. Works perfectly fine even with |
We're actually moving AWAY from Swiper, because it's awful to use and customize, and has zero Angular support. Interesting to hear that you actually prefer it to Owl-carousel. |
I implemented the same example that was given here: https://github.com/vitalii-andriiovskyi/ngx-owl-carousel-o/blob/develop/apps/demo-owl-carousel/src/app/link/link.component.html
And followed the documentation. It appears that, while dragging my carousel for the first time, it works. But now when i try to click, drag again, and unclick, the carousel item gets clicked. I don't want the items to be clicked after i'm done dragging.
TLDR; dragging works only for the first time, but every next time the carousel item gets clicked after dragging.
Can you reproduce this and let me know if this is a bug, and how to fix this?
The text was updated successfully, but these errors were encountered: