svelte-remote-image 0.2.1 → 0.2.3
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script>import { browser } from "$app/environment";
|
|
2
|
-
import { afterUpdate
|
|
2
|
+
import { afterUpdate } from "svelte";
|
|
3
3
|
export let src;
|
|
4
4
|
export let style = "";
|
|
5
|
-
const
|
|
5
|
+
export const alt = "";
|
|
6
|
+
export const title = "";
|
|
7
|
+
const imgId = `svelte-remote-image-${alt.replaceAll(" ", "-")}-${Math.round(Math.random() * 1e7)}`;
|
|
6
8
|
const getImgElement = () => browser ? document.getElementById(imgId) : null;
|
|
7
9
|
let loadStatus = "loading";
|
|
8
10
|
$: {
|
|
@@ -25,7 +27,6 @@ afterUpdate(async () => {
|
|
|
25
27
|
if (!img) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
|
-
await tick();
|
|
29
30
|
if (img.naturalWidth !== 0 && img.naturalHeight !== 0) {
|
|
30
31
|
img.style.visibility = "visible";
|
|
31
32
|
loadStatus = "loaded";
|
|
@@ -90,7 +91,8 @@ const handleLoaded = (e) => {
|
|
|
90
91
|
{style}
|
|
91
92
|
class={src.blur ? `image-blur-${loadStatus}` : ''}
|
|
92
93
|
src={src.img}
|
|
93
|
-
alt={
|
|
94
|
+
alt={alt}
|
|
95
|
+
title={title}
|
|
94
96
|
on:error={handleImgError}
|
|
95
97
|
on:load={handleLoaded}
|
|
96
98
|
loading="lazy"
|
|
@@ -4,6 +4,8 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
src: ImageSrc;
|
|
6
6
|
style?: string | undefined;
|
|
7
|
+
alt?: "" | undefined;
|
|
8
|
+
title?: "" | undefined;
|
|
7
9
|
};
|
|
8
10
|
events: {
|
|
9
11
|
[evt: string]: CustomEvent<any>;
|
|
@@ -16,5 +18,7 @@ export type ImageProps = typeof __propDef.props;
|
|
|
16
18
|
export type ImageEvents = typeof __propDef.events;
|
|
17
19
|
export type ImageSlots = typeof __propDef.slots;
|
|
18
20
|
export default class Image extends SvelteComponent<ImageProps, ImageEvents, ImageSlots> {
|
|
21
|
+
get alt(): "";
|
|
22
|
+
get title(): "";
|
|
19
23
|
}
|
|
20
24
|
export {};
|