srcdev-nuxt-components 3.0.0 → 4.0.1
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/assets/styles/a11y/_utils.css +20 -0
- package/assets/styles/a11y/_variables.css +8 -0
- package/assets/styles/a11y/index.css +2 -0
- package/assets/styles/forms/index.css +2 -0
- package/assets/styles/forms/themes/_error.css +77 -0
- package/assets/styles/forms/themes/_ghost.css +77 -0
- package/assets/styles/forms/themes/_input-action.css +20 -0
- package/assets/styles/forms/themes/_primary.css +82 -0
- package/assets/styles/forms/themes/_secondary.css +77 -0
- package/assets/styles/forms/themes/_success.css +77 -0
- package/assets/styles/forms/themes/_tertiary.css +77 -0
- package/assets/styles/forms/themes/_warning.css +77 -0
- package/assets/styles/forms/themes/index.css +8 -0
- package/assets/styles/forms/variables/_sizes.css +82 -0
- package/assets/styles/forms/variables/_theme.css +11 -0
- package/assets/styles/forms/variables/index.css +2 -0
- package/assets/styles/main.css +5 -0
- package/assets/styles/typography/index.css +2 -0
- package/assets/styles/typography/utils/_font-classes.css +160 -0
- package/assets/styles/typography/utils/_weights.css +69 -0
- package/assets/styles/typography/utils/index.css +2 -0
- package/assets/styles/typography/variables/_colors.css +14 -0
- package/assets/styles/typography/variables/_reponsive-font-size.css +10 -0
- package/assets/styles/typography/variables/index.css +2 -0
- package/assets/styles/utils/_animations.css +42 -0
- package/assets/styles/utils/_canvasWidths.css +18 -0
- package/assets/styles/utils/_display.css +7 -0
- package/assets/styles/utils/_margin-helpers.css +334 -0
- package/assets/styles/utils/_padding-helpers.css +308 -0
- package/assets/styles/utils/_page.css +24 -0
- package/assets/styles/utils/_placement.css +73 -0
- package/assets/styles/utils/index.css +7 -0
- package/assets/styles/variables/colors/_blue.css +15 -0
- package/assets/styles/variables/colors/_gray.css +16 -0
- package/assets/styles/variables/colors/_green.css +15 -0
- package/assets/styles/variables/colors/_orange.css +15 -0
- package/assets/styles/variables/colors/_red.css +15 -0
- package/assets/styles/variables/colors/_yellow.css +15 -0
- package/assets/styles/variables/colors/colors.css +6 -0
- package/assets/styles/variables/components/_accordian.css +7 -0
- package/assets/styles/variables/components/_container-glow-core.css +16 -0
- package/assets/styles/variables/components/_display-dialog-core.css +35 -0
- package/assets/styles/variables/components/_tabs.css +18 -0
- package/assets/styles/variables/components/display-prompt-core/_scaffolding.css +57 -0
- package/assets/styles/variables/components/display-prompt-core/index.css +2 -0
- package/assets/styles/variables/components/display-prompt-core/themes/_error.css +39 -0
- package/assets/styles/variables/components/display-prompt-core/themes/_info.css +39 -0
- package/assets/styles/variables/components/display-prompt-core/themes/_success.css +39 -0
- package/assets/styles/variables/components/display-prompt-core/themes/_warning.css +39 -0
- package/assets/styles/variables/components/display-prompt-core/themes/index.css +4 -0
- package/assets/styles/variables/components/index.css +5 -0
- package/assets/styles/variables/index.css +2 -0
- package/components/animated-svg-text/AnimatedSvgText.vue +87 -0
- package/components/canvas-switcher/CanvasSwitcher.vue +77 -0
- package/components/carousel-basic/CarouselBasic.vue +241 -0
- package/components/carousel-basic/CarouselFlip.vue +378 -0
- package/components/clip-element/ClipElement.vue +73 -0
- package/components/clipped-panels/ClippedPanel.vue +73 -0
- package/components/deep-expanding-menu/DeepExpandingMenu.vue +214 -0
- package/components/deep-expanding-menu/DeepExpandingMenuOld.vue +218 -0
- package/components/display-banner/DisplayBanner.vue +63 -0
- package/components/display-details/DisplayDetailsCore.vue +312 -0
- package/components/functional/accordian/AccordianCore.vue +138 -0
- package/components/functional/display-dialog/DisplayDialogCore.vue +244 -0
- package/components/functional/display-dialog/variants/DisplayDialogConfirm.vue +45 -0
- package/components/functional/display-dialog/variants/DisplayDialogScrollableContent.vue +49 -0
- package/components/functional/pop-over/PopOver.vue +88 -0
- package/components/image-galleries/SliderGallery.vue +784 -0
- package/components/masonry-grid-ordered/MasonryGridOrdered.vue +158 -0
- package/components/presentation/container-glow/ContainerGlowCore.vue +211 -0
- package/components/presentation/display-grid/DisplayGridCore.vue +22 -0
- package/components/presentation/display-prompt/DisplayPromptCore.vue +150 -0
- package/components/presentation/display-prompt/variants/DisplayPromptError.vue +53 -0
- package/components/presentation/layout-grids/LayoutGridA.vue +103 -0
- package/components/presentation/layout-grids/LayoutGridB.vue +132 -0
- package/components/presentation/layout-row/LayoutRow.vue +157 -0
- package/components/presentation/masonry-grid/MasonryGrid.vue +62 -0
- package/components/presentation/masonry-grid-sorted/MasonryGridSorted.vue +115 -0
- package/components/presentation/tabs/TabsCore.vue +308 -0
- package/components/responsive-header/NavigationItems.vue +164 -0
- package/components/responsive-header/ResponsiveHeader.vue +586 -0
- package/components/rotating-carousel/RotatingCarouselImage.vue +200 -0
- package/composables/useDialogControls.ts +23 -0
- package/composables/useStyleClassPassthrough.ts +35 -0
- package/composables/useTabs.ts +201 -0
- package/nuxt.config.ts +0 -3
- package/package.json +7 -7
- package/types/gallery-data.ts +13 -0
- package/types/responsiveHeader.ts +38 -0
- package/types/types.carousel-basic.ts +19 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="carousel-basic" :class="[elementClasses]" ref="carouselWrapperRef">
|
|
3
|
+
|
|
4
|
+
<div tabindex="0" class="item-container" ref="carouselContainerRef">
|
|
5
|
+
<div v-for="(item, index) in carouselDataIds" :key="index" class="item" ref="carouselItems">
|
|
6
|
+
<slot :name="item"></slot>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="timeline-container">
|
|
11
|
+
<div v-for="index in itemCount" :key="index" class="timeline-item">
|
|
12
|
+
<div class="count">Step {{ Math.floor(index + 1) }}</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="controls-container">
|
|
17
|
+
<div class="markers-container">
|
|
18
|
+
<ul class="markers-list">
|
|
19
|
+
<li v-for="index in itemCount" :key="index" class="markers-item">
|
|
20
|
+
<button @click.prevent="jumpToFrame(index)" class="btn-marker"
|
|
21
|
+
:class="[{ active: currentIndex === index - 1}]"><span class="sr-only">Jump to item{{
|
|
22
|
+
Math.floor(index + 1) }}</span></button>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="buttons-container">
|
|
27
|
+
<button type="submit" @click.prevent="actionPrevious()" class="btn-action">Prev</button>
|
|
28
|
+
<button type="submit" @click.prevent="actionNext()" class="btn-action">Next</button>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</section>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import type { ICarouselBasic } from "@/types/types.carousel-basic";
|
|
36
|
+
import { useEventListener, useResizeObserver, useSwipe } from "@vueuse/core";
|
|
37
|
+
|
|
38
|
+
const props = defineProps({
|
|
39
|
+
carouselDataIds: {
|
|
40
|
+
type: Array as PropType<string[]>,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
styleClassPassthrough: {
|
|
44
|
+
type: Array as PropType<string[]>,
|
|
45
|
+
default: () => [],
|
|
46
|
+
},
|
|
47
|
+
transitionSpeed: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: 200
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
54
|
+
|
|
55
|
+
const carouselWrapperRef = ref<HTMLDivElement | null>(null);
|
|
56
|
+
const carouselContainerRef = ref<HTMLDivElement | null>(null);
|
|
57
|
+
const carouselItemsRef = useTemplateRef<HTMLDivElement[]>('carouselItems');
|
|
58
|
+
const carouselInitComplete = ref(false);
|
|
59
|
+
|
|
60
|
+
const currentIndex = ref(0);
|
|
61
|
+
const itemCount = ref(props.carouselDataIds.length);
|
|
62
|
+
const offset = ref(0);
|
|
63
|
+
const transitionSpeedStr = props.transitionSpeed + 'ms';
|
|
64
|
+
const itemTransform = computed(() => {
|
|
65
|
+
return `translateX(calc(${offset.value} * (${itemWidth.value} + var(--_item-gap))))`;
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const itemWidth = ref('0px');
|
|
69
|
+
|
|
70
|
+
const actionPrevious = () => {
|
|
71
|
+
if (offset.value >= 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
offset.value = Math.min(offset.value + 1);
|
|
76
|
+
doAction();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const actionNext = () => {
|
|
80
|
+
if (offset.value <= -1 * (itemCount.value - 1)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
offset.value = Math.min(offset.value - 1);
|
|
85
|
+
doAction();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const doAction = () => {
|
|
89
|
+
currentIndex.value = Math.abs(offset.value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const jumpToFrame = (index: number) => {
|
|
93
|
+
|
|
94
|
+
if (index >= 0 && index < itemCount.value) {
|
|
95
|
+
offset.value = -index;
|
|
96
|
+
doAction();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const initialSetup = () => {
|
|
101
|
+
if (carouselItemsRef?.value && carouselItemsRef.value.length > 0 && carouselItemsRef.value[0]) {
|
|
102
|
+
itemWidth.value = carouselItemsRef.value[0].offsetWidth + 'px';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
carouselInitComplete.value = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const { direction } = useSwipe(
|
|
109
|
+
carouselContainerRef,
|
|
110
|
+
{
|
|
111
|
+
passive: false,
|
|
112
|
+
onSwipeEnd() {
|
|
113
|
+
if (direction.value === 'left') {
|
|
114
|
+
actionNext();
|
|
115
|
+
} else if (direction.value === 'right') {
|
|
116
|
+
actionPrevious();
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
useEventListener(
|
|
123
|
+
carouselContainerRef,
|
|
124
|
+
'keydown',
|
|
125
|
+
(event: KeyboardEvent) => {
|
|
126
|
+
if (event.key === 'ArrowLeft') {
|
|
127
|
+
actionPrevious();
|
|
128
|
+
} else if (event.key === 'ArrowRight') {
|
|
129
|
+
actionNext();
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
useResizeObserver(carouselWrapperRef, async () => {
|
|
135
|
+
initialSetup();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
onMounted(() => {
|
|
139
|
+
initialSetup();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<style lang="css">
|
|
145
|
+
|
|
146
|
+
.carousel-basic {
|
|
147
|
+
--_item-gap: 10px;
|
|
148
|
+
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: 1fr;
|
|
151
|
+
gap: 10px;
|
|
152
|
+
|
|
153
|
+
.timeline-container {
|
|
154
|
+
display: flex;
|
|
155
|
+
gap: var(--_item-gap);
|
|
156
|
+
overflow-x: hidden;
|
|
157
|
+
|
|
158
|
+
.timeline-item {
|
|
159
|
+
display: flex;
|
|
160
|
+
flex: 0 0 100%;
|
|
161
|
+
max-inline-size: 800px;
|
|
162
|
+
align-items: center;
|
|
163
|
+
transform: v-bind(itemTransform);
|
|
164
|
+
position: relative;
|
|
165
|
+
|
|
166
|
+
&::before {
|
|
167
|
+
content: '';
|
|
168
|
+
position: absolute;
|
|
169
|
+
height: 2px;
|
|
170
|
+
background-color: #fff;
|
|
171
|
+
left: 70px;
|
|
172
|
+
right: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.count {
|
|
176
|
+
width: fit-content;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.item-container {
|
|
182
|
+
display: flex;
|
|
183
|
+
gap: var(--_item-gap);
|
|
184
|
+
overflow-x: hidden;
|
|
185
|
+
position: relative;
|
|
186
|
+
|
|
187
|
+
.item {
|
|
188
|
+
display: flex;
|
|
189
|
+
flex: 0 0 100%;
|
|
190
|
+
max-inline-size: 800px;
|
|
191
|
+
transition: transform v-bind(transitionSpeedStr) ease;
|
|
192
|
+
transform: v-bind(itemTransform);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.controls-container {
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: flex-end;
|
|
200
|
+
|
|
201
|
+
.markers-container {
|
|
202
|
+
|
|
203
|
+
.markers-list {
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: row;
|
|
206
|
+
gap: 10px;
|
|
207
|
+
list-style-type: none;
|
|
208
|
+
margin: unset;
|
|
209
|
+
padding: unset;
|
|
210
|
+
|
|
211
|
+
.markers-item {
|
|
212
|
+
|
|
213
|
+
.btn-marker {
|
|
214
|
+
border: none;
|
|
215
|
+
outline: none;
|
|
216
|
+
box-shadow: none;
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
transition: background-color v-bind(transitionSpeedStr) linear;
|
|
219
|
+
|
|
220
|
+
&.active {
|
|
221
|
+
background-color: red;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.buttons-container {
|
|
229
|
+
display: flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: end;
|
|
232
|
+
gap: 20px;
|
|
233
|
+
|
|
234
|
+
.btn-action {
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
height: fit-content;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="carousel-flip" :class="[elementClasses, { 'controls-inside': controlsInside }]">
|
|
3
|
+
|
|
4
|
+
<div class="item-container" ref="carouselContent">
|
|
5
|
+
<div v-for="(item, index) in data?.items" :key="index" class="item" ref="carouselItems">
|
|
6
|
+
<h3>{{ index }}</h3>
|
|
7
|
+
<p>{{ item.alt }}</p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div class="controls-container">
|
|
13
|
+
<div class="buttons-container">
|
|
14
|
+
<button type="submit" @click.prevent="actionPrevious()" class="btn-action"
|
|
15
|
+
:disabled="transitionRunning">Prev</button>
|
|
16
|
+
<button type="submit" @click.prevent="actionNext()" class="btn-action"
|
|
17
|
+
:disabled="transitionRunning">Next</button>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="thumbnail-container">
|
|
20
|
+
<ul class="thumbnail-list">
|
|
21
|
+
<li v-for="item, index in data?.items" class="thumbnail-item" ref="thumbnailItems">
|
|
22
|
+
<div class="thumbnail-item_inner">{{ index }}</div>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</section>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import type { ICarouselBasic } from "@/types/types.carousel-basic";
|
|
32
|
+
import { useElementSize, useEventListener, useResizeObserver } from "@vueuse/core";
|
|
33
|
+
const props = defineProps({
|
|
34
|
+
propsData: {
|
|
35
|
+
type: Object as PropType<ICarouselBasic>,
|
|
36
|
+
default: <ICarouselBasic>{
|
|
37
|
+
items: [],
|
|
38
|
+
total: 0,
|
|
39
|
+
skip: 0,
|
|
40
|
+
limit: 10
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
data: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: <ICarouselBasic>{}
|
|
46
|
+
},
|
|
47
|
+
styleClassPassthrough: {
|
|
48
|
+
type: Array as PropType<string[]>,
|
|
49
|
+
default: () => [],
|
|
50
|
+
},
|
|
51
|
+
transitionSpeed: {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: 1000
|
|
54
|
+
},
|
|
55
|
+
controlsInside: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
62
|
+
|
|
63
|
+
const carouselContentRef = useTemplateRef<HTMLDivElement>('carouselContent');
|
|
64
|
+
const carouselItems = useTemplateRef<HTMLDivElement[]>('carouselItems');
|
|
65
|
+
const thumbnailItems = useTemplateRef<HTMLLIElement[]>('thumbnailItems');
|
|
66
|
+
const carouselInitComplete = ref(false);
|
|
67
|
+
|
|
68
|
+
const currentIndex = ref(1);
|
|
69
|
+
const itemCount = ref(props.data.items.length);
|
|
70
|
+
const offset = ref(1);
|
|
71
|
+
const previousOffset = ref(1);
|
|
72
|
+
const transitionSpeedStr = props.transitionSpeed + 'ms';
|
|
73
|
+
const transitionRunning = ref(false);
|
|
74
|
+
|
|
75
|
+
const actionPrevious = () => {
|
|
76
|
+
// if (transitionRunning.value) return;
|
|
77
|
+
|
|
78
|
+
offset.value = -1;
|
|
79
|
+
onTransitionEnd();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const actionNext = () => {
|
|
83
|
+
// if (transitionRunning.value) return;
|
|
84
|
+
|
|
85
|
+
offset.value = 1;
|
|
86
|
+
onTransitionEnd();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const updateOrder = (index: number, order: number) => {
|
|
90
|
+
if (carouselItems.value !== null && thumbnailItems.value !== null) {
|
|
91
|
+
carouselItems.value[index - 1].style.order = order.toString();
|
|
92
|
+
thumbnailItems.value[index - 1].style.order = order.toString();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const initialSetup = () => {
|
|
97
|
+
const items = carouselItems.value;
|
|
98
|
+
const thumbs = thumbnailItems.value;
|
|
99
|
+
|
|
100
|
+
items?.forEach((item, index) => {
|
|
101
|
+
item.style.zIndex = index === 0 || index === itemCount.value - 1 ? '1' : '2';
|
|
102
|
+
item.style.order = String(index + 1);
|
|
103
|
+
// item.setAttribute('data-order', String(index + 1));
|
|
104
|
+
});
|
|
105
|
+
thumbs?.forEach((thumb, index) => {
|
|
106
|
+
thumb.style.zIndex = index === 0 || index === itemCount.value - 1 ? '1' : '2';
|
|
107
|
+
thumb.style.order = String(index + 1);
|
|
108
|
+
// thumb.setAttribute('data-order', String(index + 1));
|
|
109
|
+
});
|
|
110
|
+
carouselInitComplete.value = true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
const onTransitionEnd = () => {
|
|
115
|
+
|
|
116
|
+
// transitionRunning.value = true;
|
|
117
|
+
const items = carouselItems.value;
|
|
118
|
+
const thumbs = thumbnailItems.value;
|
|
119
|
+
|
|
120
|
+
if (!items || !Array.isArray(items)) return;
|
|
121
|
+
if (!thumbs || !Array.isArray(thumbs)) return;
|
|
122
|
+
|
|
123
|
+
// 1. Capture initial positions for both main items and thumbnails
|
|
124
|
+
const firstRects = items.map(el => el.getBoundingClientRect());
|
|
125
|
+
const firstThumbRects = thumbs.map(el => el.getBoundingClientRect());
|
|
126
|
+
|
|
127
|
+
// 2. Update orders
|
|
128
|
+
let firstVisualElementIndex = currentIndex.value; // Track which element should be visually first
|
|
129
|
+
|
|
130
|
+
if (carouselInitComplete.value) {
|
|
131
|
+
if (offset.value === 1) {
|
|
132
|
+
const localOffset = offset.value === previousOffset.value ? offset.value : 2; // Ensure we have a valid offset
|
|
133
|
+
currentIndex.value = currentIndex.value === itemCount.value ? 1 : currentIndex.value + localOffset;
|
|
134
|
+
firstVisualElementIndex = currentIndex.value;
|
|
135
|
+
let order = 1;
|
|
136
|
+
|
|
137
|
+
for (let i = currentIndex.value; i <= itemCount.value; i++) updateOrder(i, order++);
|
|
138
|
+
for (let i = 1; i < currentIndex.value; i++) updateOrder(i, order++);
|
|
139
|
+
|
|
140
|
+
} else {
|
|
141
|
+
const localOffset = offset.value === previousOffset.value ? offset.value : -2; // Ensure we have a valid offset
|
|
142
|
+
currentIndex.value = currentIndex.value === 1 ? itemCount.value : currentIndex.value + localOffset;
|
|
143
|
+
firstVisualElementIndex = currentIndex.value;
|
|
144
|
+
let order = itemCount.value;
|
|
145
|
+
|
|
146
|
+
for (let i = currentIndex.value; i >= 1; i--) updateOrder(i, order--);
|
|
147
|
+
for (let i = itemCount.value; i > currentIndex.value; i--) updateOrder(i, order--);
|
|
148
|
+
}
|
|
149
|
+
previousOffset.value = offset.value; // Store the previous offset for next transition
|
|
150
|
+
|
|
151
|
+
// setTimeout(() => {
|
|
152
|
+
// transitionRunning.value = false;
|
|
153
|
+
// }, props.transitionSpeed);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 3. Next tick: capture new positions & animate both main items and thumbnails
|
|
157
|
+
requestAnimationFrame(() => {
|
|
158
|
+
const lastRects = items.map(el => el.getBoundingClientRect());
|
|
159
|
+
const lastThumbRects = thumbs.map(el => el.getBoundingClientRect());
|
|
160
|
+
|
|
161
|
+
// Animate main carousel items
|
|
162
|
+
items.forEach((el, i) => {
|
|
163
|
+
const dx = firstRects[i].left - lastRects[i].left;
|
|
164
|
+
const dy = firstRects[i].top - lastRects[i].top;
|
|
165
|
+
|
|
166
|
+
el.style.transition = 'none';
|
|
167
|
+
el.style.transform = `translate(${dx}px, ${dy}px)`;
|
|
168
|
+
|
|
169
|
+
requestAnimationFrame(() => {
|
|
170
|
+
el.style.transition = `transform ${transitionSpeedStr} ease`;
|
|
171
|
+
el.style.transform = '';
|
|
172
|
+
|
|
173
|
+
// Set z-index after the transition actually completes
|
|
174
|
+
const elementIndex = i + 1; // Convert to 1-based index to match your logic
|
|
175
|
+
const isFirstVisual = elementIndex === firstVisualElementIndex;
|
|
176
|
+
|
|
177
|
+
// Listen for transition end to update z-index
|
|
178
|
+
const handleTransitionEnd = (event: TransitionEvent) => {
|
|
179
|
+
if (event.propertyName === 'transform') {
|
|
180
|
+
el.style.zIndex = isFirstVisual ? '1' : '2';
|
|
181
|
+
el.removeEventListener('transitionend', handleTransitionEnd);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
el.addEventListener('transitionend', handleTransitionEnd);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Animate thumbnail items
|
|
190
|
+
thumbs.forEach((thumb, i) => {
|
|
191
|
+
const dx = firstThumbRects[i].left - lastThumbRects[i].left;
|
|
192
|
+
const dy = firstThumbRects[i].top - lastThumbRects[i].top;
|
|
193
|
+
|
|
194
|
+
thumb.style.transition = 'none';
|
|
195
|
+
thumb.style.transform = `translate(${dx}px, ${dy}px)`;
|
|
196
|
+
|
|
197
|
+
requestAnimationFrame(() => {
|
|
198
|
+
thumb.style.transition = `transform ${transitionSpeedStr} ease`;
|
|
199
|
+
thumb.style.transform = '';
|
|
200
|
+
|
|
201
|
+
// Set z-index after the transition actually completes
|
|
202
|
+
const thumbIndex = i + 1; // Convert to 1-based index
|
|
203
|
+
const isActiveThumbnail = thumbIndex === firstVisualElementIndex;
|
|
204
|
+
|
|
205
|
+
// Listen for transition end to update z-index
|
|
206
|
+
const handleThumbTransitionEnd = (event: TransitionEvent) => {
|
|
207
|
+
if (event.propertyName === 'transform') {
|
|
208
|
+
thumb.style.zIndex = isActiveThumbnail ? '1' : '2';
|
|
209
|
+
thumb.removeEventListener('transitionend', handleThumbTransitionEnd);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
thumb.addEventListener('transitionend', handleThumbTransitionEnd);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
carouselInitComplete.value = true;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
onMounted(() => {
|
|
222
|
+
initialSetup();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
</script>
|
|
226
|
+
|
|
227
|
+
<style lang="css">
|
|
228
|
+
.carousel-flip {
|
|
229
|
+
|
|
230
|
+
display: grid;
|
|
231
|
+
grid-template-columns: 1fr;
|
|
232
|
+
gap: 10px;
|
|
233
|
+
|
|
234
|
+
&.controls-inside {
|
|
235
|
+
grid-template-areas: "carousel-content";
|
|
236
|
+
isolation: isolate;
|
|
237
|
+
|
|
238
|
+
.item-container {
|
|
239
|
+
grid-area: carousel-content;
|
|
240
|
+
z-index: 1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.controls-container {
|
|
244
|
+
grid-area: carousel-content;
|
|
245
|
+
z-index: 2;
|
|
246
|
+
height: fit-content;
|
|
247
|
+
align-self: flex-end;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.item-container {
|
|
252
|
+
display: flex;
|
|
253
|
+
gap: 10px;
|
|
254
|
+
overflow-x: auto;
|
|
255
|
+
padding-block: 10px;
|
|
256
|
+
padding-inline: 10px;
|
|
257
|
+
outline: 1px solid light-dark(#00000090, #f00ff090);
|
|
258
|
+
|
|
259
|
+
/* scroll-snap-type: x mandatory; */
|
|
260
|
+
|
|
261
|
+
/* isolation: isolate; */
|
|
262
|
+
position: relative;
|
|
263
|
+
|
|
264
|
+
.item {
|
|
265
|
+
display: flex;
|
|
266
|
+
flex-direction: column;
|
|
267
|
+
align-items: center;
|
|
268
|
+
justify-content: center;
|
|
269
|
+
|
|
270
|
+
/* transition: transform v-bind(transitionSpeedStr) ease; */
|
|
271
|
+
/* For FLIP smoothness */
|
|
272
|
+
|
|
273
|
+
aspect-ratio: 4 / 3;
|
|
274
|
+
|
|
275
|
+
min-inline-size: 600px;
|
|
276
|
+
color: light-dar(#aaa, #333);
|
|
277
|
+
padding-block: 10px;
|
|
278
|
+
padding-inline: 10px;
|
|
279
|
+
border-radius: 4px;
|
|
280
|
+
outline: 1px solid light-dark(#00000090, #f00ff090);
|
|
281
|
+
|
|
282
|
+
background-color: light-dark(#f00, #00f);
|
|
283
|
+
|
|
284
|
+
/* scroll-snap-align: none center; */
|
|
285
|
+
|
|
286
|
+
&:nth-child(odd) {
|
|
287
|
+
background-color: light-dark(#00f, #f00);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
.controls-container {
|
|
294
|
+
|
|
295
|
+
display: flex;
|
|
296
|
+
gap: 20px;
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
.buttons-container {
|
|
301
|
+
display: flex;
|
|
302
|
+
flex-grow: 1;
|
|
303
|
+
align-items: center;
|
|
304
|
+
justify-content: end;
|
|
305
|
+
gap: 20px;
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
.btn-action {
|
|
309
|
+
padding: 10px 20px;
|
|
310
|
+
border-radius: 4px;
|
|
311
|
+
background-color: light-dark(#000, #fff);
|
|
312
|
+
color: light-dark(#fff, #000);
|
|
313
|
+
border: none;
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
height: fit-content;
|
|
316
|
+
|
|
317
|
+
transition: background-color 0.3s ease, color 0.3s ease;
|
|
318
|
+
|
|
319
|
+
&:hover {
|
|
320
|
+
background-color: light-dark(#0009, #fff9);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
&:active {
|
|
324
|
+
background-color: light-dark(#0009, #fff9);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
&:disabled {
|
|
328
|
+
background-color: light-dark(#0003, #fff3);
|
|
329
|
+
cursor: not-allowed;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.thumbnail-container {
|
|
335
|
+
padding-block: 10px;
|
|
336
|
+
padding-inline: 10px;
|
|
337
|
+
outline: 1px solid light-dark(#00000090, #f00ff090);
|
|
338
|
+
max-inline-size: 40%;
|
|
339
|
+
|
|
340
|
+
.thumbnail-list {
|
|
341
|
+
display: flex;
|
|
342
|
+
gap: 10px;
|
|
343
|
+
list-style-type: none;
|
|
344
|
+
padding-block: 8px;
|
|
345
|
+
padding-inline: 8px;
|
|
346
|
+
margin-block: 0;
|
|
347
|
+
margin-inline: 0;
|
|
348
|
+
|
|
349
|
+
outline: 1px solid light-dark(#00000090, #f00ff090);
|
|
350
|
+
overflow-x: auto;
|
|
351
|
+
|
|
352
|
+
.thumbnail-item {
|
|
353
|
+
|
|
354
|
+
display: flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
justify-content: center;
|
|
357
|
+
|
|
358
|
+
aspect-ratio: 3 / 4;
|
|
359
|
+
min-inline-size: 120px;
|
|
360
|
+
outline: 1px solid light-dark(#f00, #00f);
|
|
361
|
+
border-radius: 4px;
|
|
362
|
+
|
|
363
|
+
background-color: light-dark(#f00, #00f);
|
|
364
|
+
|
|
365
|
+
&:nth-child(odd) {
|
|
366
|
+
background-color: light-dark(#00f, #f00);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
.thumbnail-item_inner {}
|
|
371
|
+
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
}
|
|
378
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="clip-element-wrapper" ref="container" :class="elementClasses">
|
|
3
|
+
<div class="clipped-element" :style="`--_clip-path: inset(${clipOffset}px 0 0 0)`" ref="clipElement">
|
|
4
|
+
<slot name="default"></slot>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
maxClip: {
|
|
13
|
+
type: Number,
|
|
14
|
+
default: 100,
|
|
15
|
+
},
|
|
16
|
+
styleClassPassthrough: {
|
|
17
|
+
type: Array as PropType<string[]>,
|
|
18
|
+
default: () => [],
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const container = ref(null);
|
|
26
|
+
const clipElement = ref<HTMLDivElement | null>(null);
|
|
27
|
+
const clipOffset = ref(0);
|
|
28
|
+
|
|
29
|
+
const updateClip = () => {
|
|
30
|
+
|
|
31
|
+
if (clipElement.value) {
|
|
32
|
+
|
|
33
|
+
const topPosition = Math.floor(clipElement.value.getBoundingClientRect().top);
|
|
34
|
+
|
|
35
|
+
if (topPosition < props.maxClip && topPosition > 0) {
|
|
36
|
+
clipOffset.value = props.maxClip - topPosition;
|
|
37
|
+
}
|
|
38
|
+
else if (topPosition < 0) {
|
|
39
|
+
clipOffset.value = props.maxClip + Math.abs(topPosition);
|
|
40
|
+
}
|
|
41
|
+
else if (topPosition > props.maxClip) {
|
|
42
|
+
clipOffset.value = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
|
|
49
|
+
if (import.meta.client) {
|
|
50
|
+
updateClip(); // Initial check
|
|
51
|
+
window.addEventListener('scroll', updateClip, { passive: true });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
onBeforeUnmount(() => {
|
|
57
|
+
window.removeEventListener('scroll', updateClip);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<style lang="css">
|
|
64
|
+
.clip-element-wrapper {
|
|
65
|
+
position: relative;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
.clipped-element {
|
|
69
|
+
width: 100%;
|
|
70
|
+
clip-path: var(--_clip-path);
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
</style>
|