material2-carousel
material2-carousel copied to clipboard
Goes to first slide on window resize
Bug.
To reproduce:
- Open demo
- Go to the second slide
- Resize window
Expected behavior:
- Resizing window should not trigger sliding
Very annoying on mobile devices where the address bar is shown/hidden automatically.
Since this is done on purpose, it is easily reversible. I'll take a look, thanks for the feedback.
Great library, but same problem here when triggering full-screen from a slide's content (e.g. when an HTML5 video on a slide needs to be launched in full-screen mode) as this also triggers the "resize" event.
https://github.com/gbrlsnchs/material2-carousel/blob/f7df95d3b4fd2702c603227f3cf854a9e001ed57/projects/carousel/src/lib/carousel.component.ts#L244
@HostListener('window:resize', ['$event'])
public onResize(event: Event): void {
// Reset carousel when window is resized
// in order to avoid major glitches.
this.slideTo(0);
}
@gbrlsnchs can you please tell me, do these problems still need to be addressed and what kind of problems are they? I would be interested to take a look and submit a PR, if that's ok.
Can we reverse it, or will it lead to major glitches? Can they be mitigated in other ways?