@getflip/swirl-components 0.271.0 → 0.273.0
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/components.json +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-date-picker_2.cjs.entry.js +10 -1
- package/dist/cjs/swirl-image-grid-item.cjs.entry.js +10 -8
- package/dist/collection/components/swirl-date-picker/swirl-date-picker.js +12 -3
- package/dist/collection/components/swirl-date-picker/swirl-date-picker.spec.js +1 -1
- package/dist/collection/components/swirl-image-grid-item/swirl-image-grid-item.js +10 -8
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-date-picker2.js +11 -2
- package/dist/components/swirl-image-grid-item.js +10 -8
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-date-picker_2.entry.js +10 -1
- package/dist/esm/swirl-image-grid-item.entry.js +10 -8
- package/dist/swirl-components/p-0e41e194.entry.js +1 -0
- package/dist/swirl-components/p-9f04f82d.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-date-picker/swirl-date-picker.d.ts +1 -0
- package/dist/types/components/swirl-image-grid-item/swirl-image-grid-item.d.ts +1 -1
- package/package.json +1 -1
- package/dist/swirl-components/p-7a566f48.entry.js +0 -1
- package/dist/swirl-components/p-ed56e02a.entry.js +0 -1
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { debounce } from "../../utils";
|
|
3
4
|
export class SwirlImageGridItem {
|
|
4
5
|
constructor() {
|
|
6
|
+
this.handleIntersectionEntries = debounce((entries) => {
|
|
7
|
+
const sorted = [...entries].sort((a, b) => a.time - b.time);
|
|
8
|
+
this.inViewport = sorted.at(-1).isIntersecting;
|
|
9
|
+
}, 250);
|
|
5
10
|
this.onLoad = () => {
|
|
6
11
|
this.error = false;
|
|
7
12
|
this.loaded = true;
|
|
@@ -76,14 +81,11 @@ export class SwirlImageGridItem {
|
|
|
76
81
|
if (this.loading !== "intersecting") {
|
|
77
82
|
return;
|
|
78
83
|
}
|
|
79
|
-
this.intersectionObserver = new IntersectionObserver(
|
|
80
|
-
|
|
84
|
+
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
85
|
+
this.handleIntersectionEntries(entries);
|
|
81
86
|
});
|
|
82
87
|
this.intersectionObserver.observe(this.el);
|
|
83
88
|
}
|
|
84
|
-
onVisibilityChange(entries) {
|
|
85
|
-
this.inViewport = entries.some((entry) => entry.isIntersecting);
|
|
86
|
-
}
|
|
87
89
|
async pauseGif() {
|
|
88
90
|
const imageEl = this.img;
|
|
89
91
|
const staticImage = await this.readImageFromCanvas(imageEl.src);
|
|
@@ -117,16 +119,16 @@ export class SwirlImageGridItem {
|
|
|
117
119
|
"image-grid-item--has-error": this.error,
|
|
118
120
|
"image-grid-item--has-overlay": this.overlay,
|
|
119
121
|
});
|
|
120
|
-
return (h(Host, { key: '
|
|
122
|
+
return (h(Host, { key: '3df6b790bbb8606b4eed5d6d0788d105e04f4b8a', "data-sibling-count": siblingCount, role: "listitem" }, h(Tag, { key: 'bb91bd8a691464f03e90ed9e89149f395df74a9d', class: className, type: this.interactive ? "button" : undefined }, h("div", { key: '8c1193c46a7d739a0b0980bbb8ba1fc6085800d7', class: "image-grid-item__background", style: {
|
|
121
123
|
backgroundImage: showBlurredBackground
|
|
122
124
|
? `url(${this.computedSrc})`
|
|
123
125
|
: undefined,
|
|
124
126
|
} }), this.loading !== "intersecting" ||
|
|
125
127
|
this.inViewport ||
|
|
126
|
-
this.gifPaused ? (h("img", { alt: this.alt, class: "image-grid-item__image", loading: this.loading !== "intersecting" ? this.loading : undefined, onError: this.onError, onLoad: this.onLoad, ref: (el) => (this.img = el), src: this.computedSrc })) : (h("div", { class: "image-grid-item__loading-placeholder" })), this.showGifControls && (h("swirl-stack", { key: '
|
|
128
|
+
this.gifPaused ? (h("img", { alt: this.alt, class: "image-grid-item__image", loading: this.loading !== "intersecting" ? this.loading : undefined, onError: this.onError, onLoad: this.onLoad, ref: (el) => (this.img = el), src: this.computedSrc })) : (h("div", { class: "image-grid-item__loading-placeholder" })), this.showGifControls && (h("swirl-stack", { key: 'ddbdaa408afe0d8fe445256196a23ace3c0fb75b', class: "image-grid-item__gif-controls", orientation: "horizontal", spacing: "4" }, h("button", { key: 'd0d2b4ca348272191442dba90619f4ac9a1bd7ec', class: "image-grid-item__gif-controls__icon image-grid-item__gif-controls__icon--button", onClick: this.handleControlClick, type: "button", "aria-label": this.gifPaused ? this.gifPlayLabel : this.gifPauseLabel }, this.gifPaused ? (h("swirl-icon-play-arrow", { size: 20 })) : (h("swirl-icon-pause", { size: 20 }))), h("div", { key: '2818e0abc2a61e1483a69c32678c2ac4e4989290', class: "image-grid-item__gif-controls__icon image-grid-item__gif-controls__icon--label" }, h("swirl-icon-gif", { key: 'c514991c015cd6f9767dd175f2370eb20937eeda', size: 20 })))), this.loaded &&
|
|
127
129
|
!this.error &&
|
|
128
130
|
this.icon &&
|
|
129
|
-
!Boolean(this.overlay) && (h("div", { key: '
|
|
131
|
+
!Boolean(this.overlay) && (h("div", { key: '3fbb938d73610ca670018d66422ce58d92a2c91c', class: "image-grid-item__icon", innerHTML: this.icon })), this.overlay && (h("div", { key: '435b2fd7a8a94fbe0905636b82a1793202cb1c41', class: "image-grid-item__overlay" }, this.overlay)), !this.loaded && (h("div", { key: 'a4a2276318afe3424504a200185a038d6dc4161f', class: "image-grid-item__spinner" }, h("swirl-spinner", { key: '55a074bfe0459222049673788d7b755608fd9f27' }))), this.loaded && this.error && (h("div", { key: 'cd48b68ce0970d73fed49bad653b9de2f0f4907f', class: "image-grid-item__error" }, h("swirl-icon-error", { key: '60b1c44bb59cf45b8cf5a27528dc680100344896', color: "critical" }))))));
|
|
130
132
|
}
|
|
131
133
|
static get is() { return "swirl-image-grid-item"; }
|
|
132
134
|
static get encapsulation() { return "shadow"; }
|