srcdev-nuxt-components 6.1.21 → 6.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/components/accordian/AccordianCore.vue +1 -1
- package/app/components/animated-svg-text/AnimatedSvgText.vue +5 -5
- package/app/components/carousel-basic/CarouselBasic.vue +1 -1
- package/app/components/carousel-basic/CarouselFlip.vue +154 -133
- package/app/components/carousel-basic/CarouselInfinite.vue +120 -89
- package/app/components/clip-element/ClipElement.vue +18 -28
- package/app/components/clipped-panels/ClippedPanel.vue +1 -1
- package/app/components/container-glow/ContainerGlowCore.vue +62 -39
- package/app/components/deep-expanding-menu/DeepExpandingMenu.vue +1 -1
- package/app/components/deep-expanding-menu/DeepExpandingMenuOld.vue +1 -1
- package/app/components/display-banner/DisplayBanner.vue +1 -1
- package/app/components/display-card/DisplayCard.vue +1 -1
- package/app/components/display-details/DisplayDetailsCore.vue +1 -1
- package/app/components/display-dialog/DisplayDialogCore.vue +1 -1
- package/app/components/display-dialog/variants/DisplayDialogConfirm.vue +2 -2
- package/app/components/display-dialog/variants/DisplayDialogScrollableContent.vue +2 -2
- package/app/components/display-grid/DisplayGridCore.vue +4 -4
- package/app/components/display-prompt/DisplayPromptCore.vue +1 -1
- package/app/components/display-prompt/variants/DisplayPromptError.vue +1 -1
- package/app/components/display-toast/DisplayToast.vue +1 -1
- package/app/components/expanding-panel/ExpandingPanel.vue +1 -1
- package/app/components/glowing-border/GlowingBorder.vue +1 -1
- package/app/components/image-galleries/SliderGallery.vue +104 -103
- package/app/components/layout-grids/LayoutGridA.vue +5 -5
- package/app/components/layout-grids/LayoutGridB.vue +10 -10
- package/app/components/layout-row/LayoutRow.vue +1 -1
- package/app/components/magnetic-navigation/MagneticNavigation.vue +1 -1
- package/app/components/masonry-grid/MasonryGrid.vue +12 -8
- package/app/components/masonry-grid-ordered/MasonryGridOrdered.vue +1 -1
- package/app/components/masonry-grid-sorted/MasonryGridSorted.vue +26 -21
- package/app/components/parallax/SectionParallax.vue +1 -1
- package/app/components/pop-over/PopOver.vue +4 -4
- package/app/components/responsive-header/NavigationItems.vue +1 -1
- package/app/components/responsive-header/ResponsiveHeader.vue +1 -1
- package/app/components/rotating-carousel/RotatingCarouselImage.vue +1 -1
- package/app/components/tabs/TabsCore.vue +41 -20
- package/app/components/typography/HeaderBlock.vue +40 -0
- package/app/composables/useStyleClassPassthrough.ts +19 -22
- package/package.json +1 -1
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
const props = defineProps({
|
|
9
9
|
styleClassPassthrough: {
|
|
10
|
-
type: Array as PropType<string[]>,
|
|
10
|
+
type: [String, Array] as PropType<string | string[]>,
|
|
11
11
|
default: () => [],
|
|
12
12
|
},
|
|
13
|
-
})
|
|
13
|
+
})
|
|
14
14
|
|
|
15
|
-
const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
15
|
+
const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
16
16
|
|
|
17
17
|
watch(
|
|
18
18
|
() => props.styleClassPassthrough,
|
|
19
19
|
() => {
|
|
20
|
-
resetElementClasses(props.styleClassPassthrough)
|
|
20
|
+
resetElementClasses(props.styleClassPassthrough)
|
|
21
21
|
}
|
|
22
|
-
)
|
|
22
|
+
)
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
25
|
<style lang="css">
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<section
|
|
3
|
-
|
|
2
|
+
<section
|
|
3
|
+
class="carousel-flip"
|
|
4
|
+
:class="[elementClasses]"
|
|
5
|
+
ref="carouselWrapperRef"
|
|
6
|
+
role="region"
|
|
7
|
+
aria-label="Image carousel"
|
|
8
|
+
>
|
|
9
|
+
<div aria-live="polite" aria-atomic="true" class="sr-only">
|
|
10
|
+
Item {{ currentActiveIndex + 1 }} of {{ itemCount }}
|
|
11
|
+
</div>
|
|
4
12
|
|
|
5
13
|
<LayoutRow tag="div" variant="full-width" :style-class-passthrough="['mbe-20']">
|
|
6
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
tabindex="0"
|
|
16
|
+
class="item-container"
|
|
17
|
+
:class="{ 'allow-overflow': allowCarouselOverflow }"
|
|
18
|
+
ref="carouselContainerRef"
|
|
19
|
+
role="group"
|
|
20
|
+
aria-label="Carousel items"
|
|
21
|
+
>
|
|
7
22
|
<div
|
|
8
23
|
v-for="(item, index) in carouselDataIds"
|
|
9
24
|
:key="index"
|
|
@@ -46,7 +61,7 @@
|
|
|
46
61
|
</template>
|
|
47
62
|
|
|
48
63
|
<script setup lang="ts">
|
|
49
|
-
import { useEventListener, useResizeObserver, useSwipe } from
|
|
64
|
+
import { useEventListener, useResizeObserver, useSwipe } from "@vueuse/core"
|
|
50
65
|
|
|
51
66
|
const props = defineProps({
|
|
52
67
|
carouselDataIds: {
|
|
@@ -54,7 +69,7 @@ const props = defineProps({
|
|
|
54
69
|
default: () => [],
|
|
55
70
|
},
|
|
56
71
|
styleClassPassthrough: {
|
|
57
|
-
type: Array as PropType<string[]>,
|
|
72
|
+
type: [String, Array] as PropType<string | string[]>,
|
|
58
73
|
default: () => [],
|
|
59
74
|
},
|
|
60
75
|
transitionSpeed: {
|
|
@@ -69,289 +84,289 @@ const props = defineProps({
|
|
|
69
84
|
type: Boolean,
|
|
70
85
|
default: true,
|
|
71
86
|
},
|
|
72
|
-
})
|
|
87
|
+
})
|
|
73
88
|
|
|
74
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
89
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
75
90
|
|
|
76
|
-
const carouselWrapperRef = ref<HTMLDivElement | null>(null)
|
|
77
|
-
const carouselContainerRef = ref<HTMLDivElement | null>(null)
|
|
78
|
-
const carouselItemsRef = useTemplateRef<HTMLDivElement[]>(
|
|
79
|
-
const controlsContainerRef = ref<HTMLDivElement | null>(null)
|
|
80
|
-
const carouselInitComplete = ref(false)
|
|
81
|
-
const userHasInteracted = ref(false)
|
|
91
|
+
const carouselWrapperRef = ref<HTMLDivElement | null>(null)
|
|
92
|
+
const carouselContainerRef = ref<HTMLDivElement | null>(null)
|
|
93
|
+
const carouselItemsRef = useTemplateRef<HTMLDivElement[]>("carouselItems")
|
|
94
|
+
const controlsContainerRef = ref<HTMLDivElement | null>(null)
|
|
95
|
+
const carouselInitComplete = ref(false)
|
|
96
|
+
const userHasInteracted = ref(false)
|
|
82
97
|
|
|
83
98
|
const initialItemOffset = computed(() => {
|
|
84
|
-
return props.useFlipAnimation ? 1 : 2
|
|
85
|
-
})
|
|
99
|
+
return props.useFlipAnimation ? 1 : 2
|
|
100
|
+
})
|
|
86
101
|
const circularOffsetBase = computed(() => {
|
|
87
|
-
return props.useFlipAnimation ? 1 : Math.floor(2 * initialItemOffset.value)
|
|
88
|
-
})
|
|
102
|
+
return props.useFlipAnimation ? 1 : Math.floor(2 * initialItemOffset.value)
|
|
103
|
+
})
|
|
89
104
|
|
|
90
105
|
function getOffsetIndex(index: number, offset: number, itemCount: number): number {
|
|
91
|
-
return (index + offset) % itemCount
|
|
106
|
+
return (index + offset) % itemCount
|
|
92
107
|
}
|
|
93
108
|
|
|
94
|
-
const currentIndex = ref(0)
|
|
95
|
-
const itemCount = ref(props.carouselDataIds.length)
|
|
96
|
-
const transitionSpeedStr = props.transitionSpeed +
|
|
109
|
+
const currentIndex = ref(0)
|
|
110
|
+
const itemCount = ref(props.carouselDataIds.length)
|
|
111
|
+
const transitionSpeedStr = props.transitionSpeed + "ms"
|
|
97
112
|
|
|
98
|
-
const itemWidth = ref(0)
|
|
113
|
+
const itemWidth = ref(0)
|
|
99
114
|
const itemWidthOffsetStr = computed(() => {
|
|
100
115
|
if (props.allowCarouselOverflow) {
|
|
101
116
|
if (props.useFlipAnimation) {
|
|
102
|
-
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - var(--_carousel-item-track-gap))
|
|
117
|
+
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - var(--_carousel-item-track-gap))` // Good
|
|
103
118
|
} else {
|
|
104
|
-
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - (2 * var(--_carousel-item-track-gap)))
|
|
119
|
+
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - (2 * var(--_carousel-item-track-gap)))` // Good
|
|
105
120
|
}
|
|
106
121
|
} else {
|
|
107
122
|
if (props.useFlipAnimation) {
|
|
108
|
-
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - var(--_carousel-item-track-gap))
|
|
123
|
+
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - var(--_carousel-item-track-gap))` // Goof
|
|
109
124
|
} else {
|
|
110
|
-
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - (2 * var(--_carousel-item-track-gap)))
|
|
125
|
+
return `calc(-${initialItemOffset.value} * ${itemWidth.value}px - (2 * var(--_carousel-item-track-gap)))` // Good
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
|
-
})
|
|
114
|
-
const currentActiveIndex = ref(0)
|
|
128
|
+
})
|
|
129
|
+
const currentActiveIndex = ref(0)
|
|
115
130
|
|
|
116
131
|
const updateItemOrder = (index: number, order: number, zIndex: number = 2) => {
|
|
117
132
|
if (carouselItemsRef?.value && carouselItemsRef.value[index]) {
|
|
118
|
-
carouselItemsRef.value[index].style.order = order.toString()
|
|
119
|
-
carouselItemsRef.value[index].style.zIndex = zIndex.toString()
|
|
133
|
+
carouselItemsRef.value[index].style.order = order.toString()
|
|
134
|
+
carouselItemsRef.value[index].style.zIndex = zIndex.toString()
|
|
120
135
|
}
|
|
121
|
-
}
|
|
136
|
+
}
|
|
122
137
|
|
|
123
138
|
function analyzeOffsets(offsets: number[]) {
|
|
124
|
-
const counts = new Map<number, number>()
|
|
139
|
+
const counts = new Map<number, number>()
|
|
125
140
|
|
|
126
141
|
offsets.forEach((val) => {
|
|
127
|
-
counts.set(val, (counts.get(val) || 0) + 1)
|
|
128
|
-
})
|
|
142
|
+
counts.set(val, (counts.get(val) || 0) + 1)
|
|
143
|
+
})
|
|
129
144
|
|
|
130
|
-
const sorted = [...counts.entries()].sort((a, b) => b[1] - a[1])
|
|
145
|
+
const sorted = [...counts.entries()].sort((a, b) => b[1] - a[1])
|
|
131
146
|
|
|
132
|
-
const majorityValue = sorted[0][0]
|
|
133
|
-
const minorityValue = sorted[sorted.length - 1][0]
|
|
134
|
-
const minorityIndex = offsets.findIndex((val) => val === minorityValue)
|
|
147
|
+
const majorityValue = sorted[0][0]
|
|
148
|
+
const minorityValue = sorted[sorted.length - 1][0]
|
|
149
|
+
const minorityIndex = offsets.findIndex((val) => val === minorityValue)
|
|
135
150
|
|
|
136
151
|
return {
|
|
137
152
|
majorityValue,
|
|
138
153
|
minorityValue,
|
|
139
154
|
minorityIndex,
|
|
140
|
-
}
|
|
155
|
+
}
|
|
141
156
|
}
|
|
142
157
|
|
|
143
|
-
const reorderItems = (direction:
|
|
144
|
-
if (!carouselItemsRef?.value) return
|
|
158
|
+
const reorderItems = (direction: "next" | "previous" | "jump" = "jump", skipAnimation: boolean = false) => {
|
|
159
|
+
if (!carouselItemsRef?.value) return
|
|
145
160
|
|
|
146
161
|
// Capture positions before reordering (only if we're going to animate)
|
|
147
|
-
const beforeRects = skipAnimation ? [] : carouselItemsRef.value.map((item) => item.getBoundingClientRect())
|
|
162
|
+
const beforeRects = skipAnimation ? [] : carouselItemsRef.value.map((item) => item.getBoundingClientRect())
|
|
148
163
|
|
|
149
164
|
// Apply new order and z-index based on direction
|
|
150
|
-
let order = 1
|
|
165
|
+
let order = 1
|
|
151
166
|
|
|
152
167
|
// For items from currentActiveIndex to end
|
|
153
168
|
for (let i = currentActiveIndex.value; i < itemCount.value; i++) {
|
|
154
|
-
let zIndex = 2
|
|
169
|
+
let zIndex = 2 // default normal z-index
|
|
155
170
|
|
|
156
171
|
if (i === currentActiveIndex.value) {
|
|
157
172
|
// The item becoming visible
|
|
158
|
-
if (direction ===
|
|
173
|
+
if (direction === "previous") {
|
|
159
174
|
// When going previous, the item moving to first position should go behind
|
|
160
|
-
zIndex = 1
|
|
175
|
+
zIndex = 1
|
|
161
176
|
} else {
|
|
162
177
|
// Normal case - visible item gets highest z-index
|
|
163
|
-
zIndex = 3
|
|
178
|
+
zIndex = 3
|
|
164
179
|
}
|
|
165
180
|
}
|
|
166
181
|
|
|
167
|
-
updateItemOrder(i, order++, zIndex)
|
|
182
|
+
updateItemOrder(i, order++, zIndex)
|
|
168
183
|
}
|
|
169
184
|
|
|
170
185
|
// For items from 0 to currentActiveIndex
|
|
171
186
|
for (let i = 0; i < currentActiveIndex.value; i++) {
|
|
172
187
|
// Items that wrap around get lower z-index to slide behind
|
|
173
|
-
const zIndex = 1
|
|
174
|
-
updateItemOrder(i, order++, zIndex)
|
|
188
|
+
const zIndex = 1
|
|
189
|
+
updateItemOrder(i, order++, zIndex)
|
|
175
190
|
}
|
|
176
191
|
|
|
177
192
|
// Skip animation if requested (for initial setup)
|
|
178
193
|
if (skipAnimation) {
|
|
179
|
-
return
|
|
194
|
+
return
|
|
180
195
|
}
|
|
181
196
|
|
|
182
197
|
// Animate using FLIP technique
|
|
183
198
|
requestAnimationFrame(() => {
|
|
184
|
-
const afterRects = carouselItemsRef.value!.map((item) => item.getBoundingClientRect())
|
|
199
|
+
const afterRects = carouselItemsRef.value!.map((item) => item.getBoundingClientRect())
|
|
185
200
|
|
|
186
201
|
// Calculate offset values
|
|
187
202
|
const offsetValues = beforeRects.map((beforeRect, index) => {
|
|
188
|
-
const afterRect = afterRects[index]
|
|
189
|
-
return beforeRect.left - afterRect.left
|
|
190
|
-
})
|
|
203
|
+
const afterRect = afterRects[index]
|
|
204
|
+
return beforeRect.left - afterRect.left
|
|
205
|
+
})
|
|
191
206
|
|
|
192
|
-
const leftValues = analyzeOffsets(offsetValues)
|
|
207
|
+
const leftValues = analyzeOffsets(offsetValues)
|
|
193
208
|
|
|
194
209
|
carouselItemsRef.value!.forEach((item, index) => {
|
|
195
|
-
const deltaX = beforeRects[index].left - afterRects[index].left
|
|
210
|
+
const deltaX = beforeRects[index].left - afterRects[index].left
|
|
196
211
|
|
|
197
212
|
if (deltaX !== 0) {
|
|
198
|
-
item.style.transition =
|
|
199
|
-
item.style.transform = `translateX(${deltaX}px)
|
|
213
|
+
item.style.transition = "none"
|
|
214
|
+
item.style.transform = `translateX(${deltaX}px)`
|
|
200
215
|
|
|
201
216
|
requestAnimationFrame(() => {
|
|
202
|
-
const shouldTransition = carouselInitComplete.value && userHasInteracted.value
|
|
203
|
-
let transitionProperties =
|
|
217
|
+
const shouldTransition = carouselInitComplete.value && userHasInteracted.value
|
|
218
|
+
let transitionProperties = "none"
|
|
204
219
|
|
|
205
220
|
if (shouldTransition) {
|
|
206
221
|
if (props.allowCarouselOverflow) {
|
|
207
222
|
if (props.useFlipAnimation) {
|
|
208
|
-
transitionProperties = `transform ${transitionSpeedStr} ease
|
|
223
|
+
transitionProperties = `transform ${transitionSpeedStr} ease`
|
|
209
224
|
} else {
|
|
210
225
|
if (leftValues.minorityIndex !== index) {
|
|
211
|
-
transitionProperties = `transform ${transitionSpeedStr} ease
|
|
226
|
+
transitionProperties = `transform ${transitionSpeedStr} ease`
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
} else {
|
|
215
230
|
if (props.useFlipAnimation) {
|
|
216
|
-
transitionProperties = `transform ${transitionSpeedStr} ease
|
|
231
|
+
transitionProperties = `transform ${transitionSpeedStr} ease`
|
|
217
232
|
} else {
|
|
218
233
|
if (leftValues.minorityIndex !== index) {
|
|
219
|
-
transitionProperties = `transform ${transitionSpeedStr} ease
|
|
234
|
+
transitionProperties = `transform ${transitionSpeedStr} ease`
|
|
220
235
|
}
|
|
221
236
|
}
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
239
|
|
|
225
|
-
item.style.transition = transitionProperties
|
|
226
|
-
item.style.transform =
|
|
240
|
+
item.style.transition = transitionProperties
|
|
241
|
+
item.style.transform = "translateX(0)"
|
|
227
242
|
|
|
228
243
|
// After animation completes, normalize z-index values
|
|
229
244
|
const handleTransitionEnd = (event: TransitionEvent) => {
|
|
230
|
-
if (event.propertyName ===
|
|
245
|
+
if (event.propertyName === "transform") {
|
|
231
246
|
// Set final z-index: current item gets highest, others get normal
|
|
232
|
-
const isCurrentlyVisible = index === currentActiveIndex.value
|
|
233
|
-
item.style.zIndex = isCurrentlyVisible ?
|
|
234
|
-
item.removeEventListener(
|
|
247
|
+
const isCurrentlyVisible = index === currentActiveIndex.value
|
|
248
|
+
item.style.zIndex = isCurrentlyVisible ? "3" : "2"
|
|
249
|
+
item.removeEventListener("transitionend", handleTransitionEnd)
|
|
235
250
|
}
|
|
236
|
-
}
|
|
251
|
+
}
|
|
237
252
|
|
|
238
253
|
if (shouldTransition) {
|
|
239
|
-
item.addEventListener(
|
|
254
|
+
item.addEventListener("transitionend", handleTransitionEnd)
|
|
240
255
|
} else {
|
|
241
256
|
// If no transition, immediately normalize z-index
|
|
242
|
-
const isCurrentlyVisible = index === currentActiveIndex.value
|
|
243
|
-
item.style.zIndex = isCurrentlyVisible ?
|
|
257
|
+
const isCurrentlyVisible = index === currentActiveIndex.value
|
|
258
|
+
item.style.zIndex = isCurrentlyVisible ? "3" : "2"
|
|
244
259
|
}
|
|
245
|
-
})
|
|
260
|
+
})
|
|
246
261
|
}
|
|
247
|
-
})
|
|
248
|
-
})
|
|
249
|
-
}
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
}
|
|
250
265
|
|
|
251
266
|
const actionPrevious = () => {
|
|
252
|
-
if (!carouselInitComplete.value || !carouselItemsRef?.value) return
|
|
267
|
+
if (!carouselInitComplete.value || !carouselItemsRef?.value) return
|
|
253
268
|
|
|
254
|
-
userHasInteracted.value = true
|
|
269
|
+
userHasInteracted.value = true
|
|
255
270
|
|
|
256
271
|
if (currentActiveIndex.value === 0) {
|
|
257
|
-
currentActiveIndex.value = itemCount.value - 1
|
|
272
|
+
currentActiveIndex.value = itemCount.value - 1
|
|
258
273
|
} else {
|
|
259
|
-
currentActiveIndex.value = currentActiveIndex.value === 0 ? itemCount.value - 1 : currentActiveIndex.value - 1
|
|
274
|
+
currentActiveIndex.value = currentActiveIndex.value === 0 ? itemCount.value - 1 : currentActiveIndex.value - 1
|
|
260
275
|
}
|
|
261
276
|
|
|
262
|
-
reorderItems(
|
|
263
|
-
currentIndex.value = currentActiveIndex.value
|
|
264
|
-
}
|
|
277
|
+
reorderItems("previous")
|
|
278
|
+
currentIndex.value = currentActiveIndex.value
|
|
279
|
+
}
|
|
265
280
|
|
|
266
281
|
const actionNext = () => {
|
|
267
|
-
if (!carouselInitComplete.value || !carouselItemsRef?.value) return
|
|
282
|
+
if (!carouselInitComplete.value || !carouselItemsRef?.value) return
|
|
268
283
|
|
|
269
|
-
userHasInteracted.value = true
|
|
284
|
+
userHasInteracted.value = true
|
|
270
285
|
|
|
271
286
|
if (currentActiveIndex.value === itemCount.value - 1) {
|
|
272
|
-
currentActiveIndex.value = 0
|
|
287
|
+
currentActiveIndex.value = 0
|
|
273
288
|
} else {
|
|
274
|
-
currentActiveIndex.value = currentActiveIndex.value === itemCount.value - 1 ? 0 : currentActiveIndex.value + 1
|
|
289
|
+
currentActiveIndex.value = currentActiveIndex.value === itemCount.value - 1 ? 0 : currentActiveIndex.value + 1
|
|
275
290
|
}
|
|
276
291
|
|
|
277
|
-
reorderItems(
|
|
278
|
-
currentIndex.value = currentActiveIndex.value
|
|
279
|
-
}
|
|
292
|
+
reorderItems("next")
|
|
293
|
+
currentIndex.value = currentActiveIndex.value
|
|
294
|
+
}
|
|
280
295
|
|
|
281
296
|
const jumpToFrame = (index: number) => {
|
|
282
297
|
if (index >= 0 && index < itemCount.value) {
|
|
283
298
|
// Only mark as user interaction if carousel is already initialized
|
|
284
299
|
if (carouselInitComplete.value) {
|
|
285
|
-
userHasInteracted.value = true
|
|
300
|
+
userHasInteracted.value = true
|
|
286
301
|
}
|
|
287
302
|
|
|
288
|
-
currentActiveIndex.value = getOffsetIndex(index, circularOffsetBase.value, itemCount.value)
|
|
303
|
+
currentActiveIndex.value = getOffsetIndex(index, circularOffsetBase.value, itemCount.value)
|
|
289
304
|
|
|
290
305
|
// currentActiveIndex.value = index;
|
|
291
|
-
reorderItems(
|
|
292
|
-
currentIndex.value = currentActiveIndex.value
|
|
306
|
+
reorderItems("jump")
|
|
307
|
+
currentIndex.value = currentActiveIndex.value
|
|
293
308
|
}
|
|
294
|
-
}
|
|
309
|
+
}
|
|
295
310
|
|
|
296
311
|
const checkAndMoveLastItem = () => {
|
|
297
312
|
if (props.allowCarouselOverflow || !props.useFlipAnimation) {
|
|
298
|
-
currentActiveIndex.value = itemCount.value - initialItemOffset.value
|
|
299
|
-
reorderItems(
|
|
300
|
-
currentIndex.value = currentActiveIndex.value
|
|
313
|
+
currentActiveIndex.value = itemCount.value - initialItemOffset.value
|
|
314
|
+
reorderItems("jump", true) // Skip animation during initial setup
|
|
315
|
+
currentIndex.value = currentActiveIndex.value
|
|
301
316
|
}
|
|
302
|
-
}
|
|
317
|
+
}
|
|
303
318
|
|
|
304
319
|
const initialSetup = () => {
|
|
305
320
|
if (carouselItemsRef?.value && carouselItemsRef.value.length > 0 && carouselItemsRef.value[0]) {
|
|
306
|
-
itemWidth.value = carouselItemsRef.value[0].offsetWidth
|
|
321
|
+
itemWidth.value = carouselItemsRef.value[0].offsetWidth
|
|
307
322
|
|
|
308
323
|
// Set initial order and z-index for all items
|
|
309
324
|
carouselItemsRef.value.forEach((item, index) => {
|
|
310
|
-
item.style.order = String(index + 1)
|
|
311
|
-
item.dataset.order = String(index + 1)
|
|
325
|
+
item.style.order = String(index + 1)
|
|
326
|
+
item.dataset.order = String(index + 1)
|
|
312
327
|
// First item gets higher z-index, others get normal z-index
|
|
313
|
-
item.style.zIndex = index === 0 ?
|
|
314
|
-
})
|
|
328
|
+
item.style.zIndex = index === 0 ? "3" : "2"
|
|
329
|
+
})
|
|
315
330
|
}
|
|
316
331
|
|
|
317
|
-
carouselInitComplete.value = true
|
|
318
|
-
checkAndMoveLastItem()
|
|
319
|
-
}
|
|
332
|
+
carouselInitComplete.value = true
|
|
333
|
+
checkAndMoveLastItem()
|
|
334
|
+
}
|
|
320
335
|
|
|
321
336
|
const { direction } = useSwipe(carouselContainerRef, {
|
|
322
337
|
passive: false,
|
|
323
338
|
onSwipeEnd() {
|
|
324
|
-
if (direction.value ===
|
|
325
|
-
actionNext()
|
|
326
|
-
} else if (direction.value ===
|
|
327
|
-
actionPrevious()
|
|
339
|
+
if (direction.value === "left") {
|
|
340
|
+
actionNext()
|
|
341
|
+
} else if (direction.value === "right") {
|
|
342
|
+
actionPrevious()
|
|
328
343
|
}
|
|
329
344
|
},
|
|
330
|
-
})
|
|
345
|
+
})
|
|
331
346
|
|
|
332
|
-
useEventListener(carouselContainerRef,
|
|
333
|
-
if (event.key ===
|
|
334
|
-
actionPrevious()
|
|
335
|
-
} else if (event.key ===
|
|
336
|
-
actionNext()
|
|
347
|
+
useEventListener(carouselContainerRef, "keydown", (event: KeyboardEvent) => {
|
|
348
|
+
if (event.key === "ArrowLeft") {
|
|
349
|
+
actionPrevious()
|
|
350
|
+
} else if (event.key === "ArrowRight") {
|
|
351
|
+
actionNext()
|
|
337
352
|
}
|
|
338
|
-
})
|
|
353
|
+
})
|
|
339
354
|
|
|
340
|
-
useEventListener(controlsContainerRef,
|
|
341
|
-
if (event.key ===
|
|
342
|
-
actionPrevious()
|
|
343
|
-
} else if (event.key ===
|
|
344
|
-
actionNext()
|
|
355
|
+
useEventListener(controlsContainerRef, "keydown", (event: KeyboardEvent) => {
|
|
356
|
+
if (event.key === "ArrowLeft") {
|
|
357
|
+
actionPrevious()
|
|
358
|
+
} else if (event.key === "ArrowRight") {
|
|
359
|
+
actionNext()
|
|
345
360
|
}
|
|
346
|
-
})
|
|
361
|
+
})
|
|
347
362
|
|
|
348
363
|
useResizeObserver(carouselWrapperRef, async () => {
|
|
349
|
-
initialSetup()
|
|
350
|
-
})
|
|
364
|
+
initialSetup()
|
|
365
|
+
})
|
|
351
366
|
|
|
352
367
|
onMounted(() => {
|
|
353
|
-
initialSetup()
|
|
354
|
-
})
|
|
368
|
+
initialSetup()
|
|
369
|
+
})
|
|
355
370
|
</script>
|
|
356
371
|
|
|
357
372
|
<style lang="css">
|
|
@@ -394,9 +409,15 @@ onMounted(() => {
|
|
|
394
409
|
|
|
395
410
|
margin-inline: auto;
|
|
396
411
|
|
|
397
|
-
max-inline-size: calc(
|
|
412
|
+
max-inline-size: calc(
|
|
413
|
+
var(--_carousel-container-max-inline-size) + var(--_carousel-item-track-gap) -
|
|
414
|
+
(2 * var(--_carousel-item-edge-preview-width))
|
|
415
|
+
);
|
|
398
416
|
|
|
399
|
-
translate: calc(
|
|
417
|
+
translate: calc(
|
|
418
|
+
v-bind(itemWidthOffsetStr) - var(--_carousel-item-track-gap) + var(--_carousel-item-edge-preview-width)
|
|
419
|
+
)
|
|
420
|
+
0;
|
|
400
421
|
|
|
401
422
|
&.loaded {
|
|
402
423
|
transition: transform v-bind(transitionSpeedStr) ease;
|