next-blurhash-previews 0.0.3-beta43 → 0.0.3-beta44
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.
@@ -10,7 +10,7 @@ class ImageWithPreview extends HTMLElement {
|
|
10
10
|
|
11
11
|
static observedAttributes = ["preview"];
|
12
12
|
|
13
|
-
#
|
13
|
+
#connected = false;
|
14
14
|
get #imgEl(): any {
|
15
15
|
return this.querySelector("img");
|
16
16
|
}
|
@@ -21,8 +21,6 @@ class ImageWithPreview extends HTMLElement {
|
|
21
21
|
constructor() {
|
22
22
|
super();
|
23
23
|
|
24
|
-
console.log("CREATED", x++);
|
25
|
-
|
26
24
|
this.sd = this.attachShadow({ mode: "open" });
|
27
25
|
this.sd.innerHTML = `<slot name="preview"></slot>`;
|
28
26
|
}
|
@@ -43,6 +41,7 @@ class ImageWithPreview extends HTMLElement {
|
|
43
41
|
};
|
44
42
|
|
45
43
|
connectedCallback() {
|
44
|
+
this.#connected = true;
|
46
45
|
if (!this.#checkReady()) {
|
47
46
|
this.mo = new MutationObserver(this.#checkReady);
|
48
47
|
this.mo.observe(this, {
|
@@ -64,12 +63,10 @@ class ImageWithPreview extends HTMLElement {
|
|
64
63
|
}
|
65
64
|
|
66
65
|
#updatePreview() {
|
67
|
-
|
68
|
-
if (this.#previewSet) {
|
66
|
+
if (!this.#connected || !this.getAttribute("preview")) {
|
69
67
|
return;
|
70
68
|
}
|
71
|
-
|
72
|
-
console.log(this.#previewSet, this.getAttribute("url"));
|
69
|
+
|
73
70
|
const previewObj = JSON.parse(this.getAttribute("preview")!);
|
74
71
|
updateBlurHashPreview(this.#canvasEl, previewObj);
|
75
72
|
}
|
package/imagePreviewBootstrap.js
CHANGED
@@ -2,12 +2,11 @@ import { createElement } from "react";
|
|
2
2
|
|
3
3
|
export const imagePreviewBootstrap = createElement("script", {
|
4
4
|
dangerouslySetInnerHTML: { __html: `(() => { "use strict";
|
5
|
-
let x = 1;
|
6
5
|
class ImageWithPreview extends HTMLElement {
|
7
6
|
sd;
|
8
7
|
mo;
|
9
8
|
static observedAttributes = ["preview"];
|
10
|
-
#
|
9
|
+
#connected = false;
|
11
10
|
get #imgEl() {
|
12
11
|
return this.querySelector("img");
|
13
12
|
}
|
@@ -16,7 +15,6 @@ class ImageWithPreview extends HTMLElement {
|
|
16
15
|
}
|
17
16
|
constructor() {
|
18
17
|
super();
|
19
|
-
console.log("CREATED", x++);
|
20
18
|
this.sd = this.attachShadow({
|
21
19
|
mode: "open"
|
22
20
|
});
|
@@ -35,6 +33,7 @@ class ImageWithPreview extends HTMLElement {
|
|
35
33
|
}
|
36
34
|
};
|
37
35
|
connectedCallback() {
|
36
|
+
this.#connected = true;
|
38
37
|
if (!this.#checkReady()) {
|
39
38
|
this.mo = new MutationObserver(this.#checkReady);
|
40
39
|
this.mo.observe(this, {
|
@@ -52,12 +51,9 @@ class ImageWithPreview extends HTMLElement {
|
|
52
51
|
}
|
53
52
|
}
|
54
53
|
#updatePreview() {
|
55
|
-
|
56
|
-
if (this.#previewSet) {
|
54
|
+
if (!this.#connected || !this.getAttribute("preview")) {
|
57
55
|
return;
|
58
56
|
}
|
59
|
-
this.#previewSet = true;
|
60
|
-
console.log(this.#previewSet, this.getAttribute("url"));
|
61
57
|
const previewObj = JSON.parse(this.getAttribute("preview"));
|
62
58
|
updateBlurHashPreview(this.#canvasEl, previewObj);
|
63
59
|
}
|