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

some android phone, element.$el.offsetWidth return 0 #51

Open Jarweb opened 3 years ago

Jarweb commented 3 years ago

Describe the bug image image

function Measure(options, element) { var $el = element.$el; console.log('viewsize', element) console.log('viewsize', element.$el.offsetWidth) setTimeout(() => { console.log('viewsize setTimeout', element.$el.offsetWidth) }, 1000) var viewSize = options.isHorizontal ? $el.offsetWidth: $el.offsetHeight; var slideSize = (viewSize - Math.ceil(options.slidesPerView - 1) * options.spaceBetween) / options.slidesPerView; var boxSize = slideSize + options.spaceBetween; return { boxSize: boxSize, viewSize: viewSize, slideSize: slideSize }; }

swiper init in react useLayoutEffect

Expected behavior

Information

joe223 commented 3 years ago

@Jarweb Hi, Would you mind create a repo or demo to reproduce this issue?

You can use https://stackblitz.com/ , just paste demo link on this comments

a-kud commented 1 year ago

@Jarweb Can you confirm this is still an issue?