@redseed/redseed-ui-vue3 2.11.15 → 2.11.17
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/package.json
CHANGED
|
@@ -30,6 +30,8 @@ const props = defineProps({
|
|
|
30
30
|
},
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
+
const imageElement = ref(null)
|
|
34
|
+
|
|
33
35
|
const large = computed(() => props.largeUrl || props.originalUrl)
|
|
34
36
|
const medium = computed(() => props.mediumUrl || props.originalUrl)
|
|
35
37
|
const small = computed(() => props.smallUrl || props.originalUrl)
|
|
@@ -84,6 +86,8 @@ const error = computed(() => {
|
|
|
84
86
|
|| smallImage.value.error
|
|
85
87
|
})
|
|
86
88
|
|
|
89
|
+
const isLoaded = ref(false)
|
|
90
|
+
|
|
87
91
|
const emit = defineEmits(['loading', 'error', 'ready'])
|
|
88
92
|
|
|
89
93
|
watch(isLoading, () => {
|
|
@@ -94,23 +98,28 @@ watch(error, () => {
|
|
|
94
98
|
if (error.value) emit('error', error.value)
|
|
95
99
|
}, { immediate: true, flush: 'post' })
|
|
96
100
|
|
|
97
|
-
watch(
|
|
98
|
-
if (
|
|
101
|
+
watch(isLoaded, () => {
|
|
102
|
+
if (isLoaded.value && isReady.value) {
|
|
103
|
+
emit('ready', {
|
|
104
|
+
ready: isReady.value,
|
|
105
|
+
imageElement: imageElement.value,
|
|
106
|
+
})
|
|
107
|
+
}
|
|
99
108
|
}, { immediate: true, flush: 'post' })
|
|
100
109
|
|
|
101
110
|
const sources = computed(() => {
|
|
102
111
|
return [
|
|
103
112
|
{
|
|
104
113
|
media: '(min-width:1280px)',
|
|
105
|
-
srcset: large.value
|
|
114
|
+
srcset: encodeURI(large.value)
|
|
106
115
|
},
|
|
107
116
|
{
|
|
108
117
|
media: '(min-width:640px)',
|
|
109
|
-
srcset: medium.value
|
|
118
|
+
srcset: encodeURI(medium.value)
|
|
110
119
|
},
|
|
111
120
|
{
|
|
112
121
|
media: '(min-width:320px)',
|
|
113
|
-
srcset: small.value
|
|
122
|
+
srcset: encodeURI(small.value)
|
|
114
123
|
},
|
|
115
124
|
]
|
|
116
125
|
})
|
|
@@ -152,7 +161,11 @@ const imageClass = computed(() => [
|
|
|
152
161
|
:media="media"
|
|
153
162
|
:srcset="srcset"
|
|
154
163
|
>
|
|
155
|
-
<img
|
|
164
|
+
<img ref="imageElement"
|
|
165
|
+
:src="originalUrl"
|
|
166
|
+
:alt="alt"
|
|
167
|
+
@load="isLoaded = true"
|
|
168
|
+
>
|
|
156
169
|
</picture>
|
|
157
170
|
</div>
|
|
158
171
|
</template>
|