Skip to content

Commit 970b83e

Browse files
committed
fix: change clientWidth to getBoundingClientRect width
1 parent c357c2f commit 970b83e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Carousel.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,13 @@ export default {
662662
*/
663663
const getCarouselWidth = () => {
664664
if (vueConciseCarousel.value) {
665-
const carouselInnerElements = vueConciseCarousel.value.getElementsByClassName(
665+
const elements = vueConciseCarousel.value.getElementsByClassName(
666666
'VueCarousel-inner'
667667
);
668-
for (let i = 0; i < carouselInnerElements.length; i++) {
669-
if (carouselInnerElements[i].clientWidth > 0) {
670-
carouselWidth.value = carouselInnerElements[i].clientWidth || 0;
668+
for (let i = 0; i < elements.length; i++) {
669+
const width = elements[i].getBoundingClientRect().width || 0;
670+
if (width > 0) {
671+
carouselWidth.value = width;
671672
}
672673
}
673674
}

0 commit comments

Comments
 (0)