-
Notifications
You must be signed in to change notification settings - Fork 4
🚸 Add nav arrows in carousel modal #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,33 +64,50 @@ | |
| :close="{ color: 'neutral', variant: 'ghost', class: 'text-white' }" | ||
| > | ||
| <template #content> | ||
| <img | ||
| v-if="modalItem?.type === 'cover' || modalItem?.type === 'image'" | ||
| :src="modalItem?.fullSrc || modalItem?.src" | ||
| :alt="props.alt" | ||
| class="w-full h-auto max-h-[80vh] object-contain" | ||
| > | ||
| <div class="relative"> | ||
| <img | ||
| v-if="modalItem?.type === 'cover' || modalItem?.type === 'image'" | ||
| :src="modalItem?.fullSrc || modalItem?.src" | ||
| :alt="props.alt" | ||
| class="w-full h-auto max-h-[80vh] object-contain" | ||
| > | ||
|
|
||
| <div | ||
| v-else-if="modalItem?.type === 'youtube' && modalItem?.videoId" | ||
| class="aspect-video" | ||
| > | ||
| <ScriptYouTubePlayer | ||
| :video-id="modalItem.videoId" | ||
| :player-vars="{ autoplay: 1, rel: 0, playsinline: 1 }" | ||
| trigger="visible" | ||
| class="w-full h-full" | ||
| /> | ||
| </div> | ||
|
|
||
| <video | ||
| v-else-if="modalItem?.type === 'video'" | ||
| :src="modalItem?.src" | ||
| controls | ||
| autoplay | ||
| playsinline | ||
| class="w-full max-h-[80vh]" | ||
| /> | ||
|
|
||
| <div | ||
| v-else-if="modalItem?.type === 'youtube' && modalItem?.videoId" | ||
| class="aspect-video" | ||
| > | ||
| <ScriptYouTubePlayer | ||
| :video-id="modalItem.videoId" | ||
| :player-vars="{ autoplay: 1, rel: 0, playsinline: 1 }" | ||
| trigger="visible" | ||
| class="w-full h-full" | ||
| <UButton | ||
| icon="i-material-symbols-chevron-left" | ||
| color="neutral" | ||
| variant="ghost" | ||
| class="absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 text-white hover:bg-black/70 cursor-pointer" | ||
| @click="navigateModal(-1)" | ||
| /> | ||
| <UButton | ||
| icon="i-material-symbols-chevron-right" | ||
| color="neutral" | ||
| variant="ghost" | ||
| class="absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 text-white hover:bg-black/70 cursor-pointer" | ||
| @click="navigateModal(1)" | ||
| /> | ||
|
Comment on lines
96
to
111
|
||
| </div> | ||
|
|
||
| <video | ||
| v-else-if="modalItem?.type === 'video'" | ||
| :src="modalItem?.src" | ||
| controls | ||
| autoplay | ||
| playsinline | ||
| class="w-full max-h-[80vh]" | ||
| /> | ||
| </template> | ||
| </UModal> | ||
| </div> | ||
|
|
@@ -141,13 +158,20 @@ const props = defineProps({ | |
| }) | ||
|
|
||
| const isModalOpen = ref(false) | ||
| const modalItem = ref<CarouselItem | null>(null) | ||
| const modalItemIndex = ref(0) | ||
| const modalItem = computed(() => carouselItems.value[modalItemIndex.value] || null) | ||
|
|
||
| function openModal(item: CarouselItem) { | ||
| modalItem.value = item | ||
| const index = carouselItems.value.indexOf(item) | ||
| modalItemIndex.value = index >= 0 ? index : 0 | ||
| isModalOpen.value = true | ||
| } | ||
|
|
||
| function navigateModal(direction: number) { | ||
| const len = carouselItems.value.length | ||
| modalItemIndex.value = (modalItemIndex.value + direction + len) % len | ||
| } | ||
|
Comment on lines
+172
to
+175
|
||
|
|
||
| const carouselItems = computed<CarouselItem[]>(() => { | ||
| const items: CarouselItem[] = [] | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not add relative to content slot