joe223 / tiny-swiper

Ingenious JavaScript Carousel powered by wonderful plugins. Lightweight yet extensible. Import plugins as needed, No more, no less.
https://tiny-swiper.js.org
1.29k stars 58 forks source link

Make Swiper resizable #67

Closed harshmandan closed 3 years ago

harshmandan commented 3 years ago

Describe the bug The swiper is not very responsive. I'm making use of this library in my project where the windows can be resized. Here's' the bug in video format: https://streamable.com/40xqoa

Expected behavior It should be responsive.

joe223 commented 3 years ago

Hi @harshmandan , Here is a demo may be useful https://github.com/joe223/tiny-swiper/blob/dev/packages/tiny-swiper/demo/resize.html

Would you like to create a Resize plugin ? It should be placed in this directory https://github.com/joe223/tiny-swiper/tree/dev/packages/tiny-swiper/src/modules

harshmandan commented 3 years ago

@joe223 Thanks for the example. This worked nicely:

window.addEventListener('resize', () => mySwiper.updateSize())

I'll try to create to module as soon as I get the time. Thanks

joe223 commented 3 years ago

Try to add a debounce function to the window resize listener for better performance

pseudocode

window.addEventListener('resize', _.debounce(() => mySwiper.updateSize(), 400))

@harshmandan