orio-ui 1.13.0 → 1.13.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/dist/module.json
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
computed,
|
|
4
|
-
nextTick,
|
|
5
|
-
onMounted,
|
|
6
|
-
ref,
|
|
7
|
-
toRefs,
|
|
8
|
-
useTemplateRef,
|
|
9
|
-
watch
|
|
10
|
-
} from "vue";
|
|
2
|
+
import { computed, onMounted, toRefs, useTemplateRef } from "vue";
|
|
11
3
|
import { useElementSize } from "@vueuse/core";
|
|
12
4
|
const props = defineProps({
|
|
13
5
|
images: { type: Array, required: false, default: () => [] },
|
|
@@ -31,8 +23,7 @@ const isDynamicWidth = computed(
|
|
|
31
23
|
const carousel = useTemplateRef("carousel");
|
|
32
24
|
const measureContainer = useTemplateRef("measureContainer");
|
|
33
25
|
const { width: carouselWidth } = useElementSize(carousel);
|
|
34
|
-
const contentWidth =
|
|
35
|
-
const contentHeight = ref(0);
|
|
26
|
+
const { width: contentWidth, height: contentHeight } = useElementSize(measureContainer);
|
|
36
27
|
const contentAspectRatio = computed(() => {
|
|
37
28
|
if (!contentWidth.value || !contentHeight.value) return 1;
|
|
38
29
|
return contentWidth.value / contentHeight.value;
|
|
@@ -65,12 +56,6 @@ const maxHeight = computed(() => {
|
|
|
65
56
|
if (!carouselWidth.value) return "100%";
|
|
66
57
|
return `${carouselWidth.value / dimensions}px`;
|
|
67
58
|
});
|
|
68
|
-
function measureContent() {
|
|
69
|
-
if (!measureContainer.value) return;
|
|
70
|
-
const el = measureContainer.value;
|
|
71
|
-
contentWidth.value = el.scrollWidth;
|
|
72
|
-
contentHeight.value = el.scrollHeight;
|
|
73
|
-
}
|
|
74
59
|
const activeImage = defineModel("activeImage", { type: String });
|
|
75
60
|
const activeImageIndex = computed(
|
|
76
61
|
() => images.value.findIndex((image) => image === activeImage.value)
|
|
@@ -111,16 +96,8 @@ function getItemClasses(image) {
|
|
|
111
96
|
if (images.value.findIndex((img) => image === img) === activeImageIndex.value - 1)
|
|
112
97
|
return ["previous-image"];
|
|
113
98
|
}
|
|
114
|
-
watch(activeImage, () => {
|
|
115
|
-
if (isDynamicHeight.value || isDynamicWidth.value) {
|
|
116
|
-
nextTick(measureContent);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
99
|
onMounted(() => {
|
|
120
100
|
if (!activeImage.value) activeImage.value = images.value[0];
|
|
121
|
-
if (isDynamicHeight.value || isDynamicWidth.value) {
|
|
122
|
-
nextTick(measureContent);
|
|
123
|
-
}
|
|
124
101
|
});
|
|
125
102
|
</script>
|
|
126
103
|
|
|
@@ -133,7 +110,7 @@ onMounted(() => {
|
|
|
133
110
|
class="carousel-measure"
|
|
134
111
|
>
|
|
135
112
|
<slot name="image" :image="activeImage">
|
|
136
|
-
<img :src="activeImage" :alt="activeImage"
|
|
113
|
+
<img :src="activeImage" :alt="activeImage" />
|
|
137
114
|
</slot>
|
|
138
115
|
</div>
|
|
139
116
|
<div ref="carousel" class="carousel">
|