From e656ed712443534f81484b5ded5bd9df78712358 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 22 Nov 2025 19:21:08 +0100 Subject: [PATCH] fix: prevent undefined error on getBoundingClientRect --- .../modal/ModalMediaPreviewCarousel.vue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/components/modal/ModalMediaPreviewCarousel.vue b/app/components/modal/ModalMediaPreviewCarousel.vue index 43eb6f7d..2e56e608 100644 --- a/app/components/modal/ModalMediaPreviewCarousel.vue +++ b/app/components/modal/ModalMediaPreviewCarousel.vue @@ -159,14 +159,16 @@ function handleTap([positionX, positionY]: Vector2) { goToFocusedSlide() } else { - const focusedSlideBounding = slide.value[modelValue.value].getBoundingClientRect() - const slideCenterX = focusedSlideBounding.left + focusedSlideBounding.width / 2 - const slideCenterY = focusedSlideBounding.top + focusedSlideBounding.height / 2 + const focusedSlideBounding = slide.value[modelValue.value]?.getBoundingClientRect() + if (focusedSlideBounding) { + const slideCenterX = focusedSlideBounding.left + focusedSlideBounding.width / 2 + const slideCenterY = focusedSlideBounding.top + focusedSlideBounding.height / 2 - scale.value = 3 - x.value += positionX - slideCenterX - y.value += positionY - slideCenterY - restrictShiftToInsideSlide() + scale.value = 3 + x.value += positionX - slideCenterX + y.value += positionY - slideCenterY + restrictShiftToInsideSlide() + } } }