@internetarchive/elements 0.2.13-webdev-9022.0 → 0.2.13-webdev-9022.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/src/elements/ia-image-viewer/ia-image-viewer.d.ts +10 -5
- package/dist/src/elements/ia-image-viewer/ia-image-viewer.d.ts.map +1 -1
- package/dist/src/elements/ia-image-viewer/ia-image-viewer.js +28 -4
- package/dist/src/elements/ia-image-viewer/ia-image-viewer.js.map +1 -1
- package/dist/src/elements/ia-image-viewer/ia-imgview-controls.d.ts +0 -5
- package/dist/src/elements/ia-image-viewer/ia-imgview-controls.d.ts.map +1 -1
- package/dist/src/elements/ia-image-viewer/ia-imgview-controls.js.map +1 -1
- package/dist/src/elements/ia-image-viewer/ia-imgview-slide.d.ts +0 -5
- package/dist/src/elements/ia-image-viewer/ia-imgview-slide.d.ts.map +1 -1
- package/dist/src/elements/ia-image-viewer/ia-imgview-slide.js.map +1 -1
- package/package.json +1 -1
|
@@ -60,6 +60,16 @@ export declare class IAImageViewer extends LitElement {
|
|
|
60
60
|
/** The image currently on screen, if there is one. */
|
|
61
61
|
get currentImage(): ImageViewerImage | undefined;
|
|
62
62
|
protected willUpdate(changed: PropertyValues): void;
|
|
63
|
+
/**
|
|
64
|
+
* Where to land when the images or the requested name change.
|
|
65
|
+
*
|
|
66
|
+
* A new `currentImageName` is the host asking for a particular image, so it
|
|
67
|
+
* wins. A new `images` array on its own isn't: a host that builds its list
|
|
68
|
+
* in a getter hands over a fresh array on every render, which says nothing
|
|
69
|
+
* about the images having changed. So the viewer holds its place by name and
|
|
70
|
+
* only goes back to the start when the image it was showing is really gone.
|
|
71
|
+
*/
|
|
72
|
+
private indexToShow;
|
|
63
73
|
render(): TemplateResult | typeof nothing;
|
|
64
74
|
private slideTemplate;
|
|
65
75
|
/**
|
|
@@ -134,9 +144,4 @@ export declare class IAImageViewer extends LitElement {
|
|
|
134
144
|
preloadAroundIndex(index: number): void;
|
|
135
145
|
static get styles(): CSSResultGroup;
|
|
136
146
|
}
|
|
137
|
-
declare global {
|
|
138
|
-
interface HTMLElementTagNameMap {
|
|
139
|
-
'ia-image-viewer': IAImageViewer;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
147
|
//# sourceMappingURL=ia-image-viewer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-image-viewer.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-image-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,UAAU,EACV,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AASb,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAY,MAAM,UAAU,CAAC;AAE3E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAK/B;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAChB,MAAM,EAAE,gBAAgB,EAAE,CAAM;IAE3D;;;OAGG;IACyB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEtD,uEAAuE;IACjD,SAAS,CAAC,EAAE,WAAW,CAAC;IAE9C,yEAAyE;IAClD,UAAU,CAAC,EAAE,WAAW,CAAC;IAEhD,gFAAgF;IACvE,YAAY,SAAK;IAEjB,OAAO,CAAC,SAAS,CAAS;IAEnC;;;;OAIG;IACM,OAAO,CAAC,eAAe,CAAK;IAErC,kEAAkE;IACzD,OAAO,CAAC,QAAQ,CAAyB;IAElD;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB,CAAqB;IAE7C,OAAO,CAAC,WAAW,CAAuB;IAE1C,OAAO,CAAC,cAAc,CAA+B;IAErD,OAAO,CAAC,QAAQ,CAAiC;IAEjD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,sDAAsD;IACtD,IAAI,YAAY,IAAI,gBAAgB,GAAG,SAAS,CAE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,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,KAAK,oBAAoB,GAW/B;IAED;;;;OAIG;IACH,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IASrB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;OAKG;IACH,gBAAgB,IAAI,IAAI;IAgBxB,gBAAgB,IAAI,IAAI;IAOxB,OAAO,CAAC,eAAe;IASvB,QAAQ,IAAI,IAAI;IAKhB,YAAY,IAAI,IAAI;IAQpB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAmBd;;;OAGG;IACH,UAAU,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAc3C;;;;OAIG;IACH,iBAAiB,IAAI,IAAI;IAMzB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,UAAU;IAMlB,8CAA8C;IAC9C,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,gBAAgB;IAUxB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;;;;;;;;OASG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAUvC,MAAM,KAAK,MAAM,IAAI,cAAc,CA+IlC;CACF"}
|
|
@@ -66,10 +66,8 @@ let IAImageViewer = class IAImageViewer extends LitElement {
|
|
|
66
66
|
}
|
|
67
67
|
willUpdate(changed) {
|
|
68
68
|
if (changed.has('images') || changed.has('currentImageName')) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
: -1;
|
|
72
|
-
this.currentIndex = requested >= 0 ? requested : 0;
|
|
69
|
+
const previous = changed.get('images');
|
|
70
|
+
this.currentIndex = this.indexToShow(changed, previous);
|
|
73
71
|
this.animating = false;
|
|
74
72
|
this.slideGeneration = 0;
|
|
75
73
|
this.slideTarget = null;
|
|
@@ -79,6 +77,32 @@ let IAImageViewer = class IAImageViewer extends LitElement {
|
|
|
79
77
|
this.preloadAdjacentImages();
|
|
80
78
|
}
|
|
81
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Where to land when the images or the requested name change.
|
|
82
|
+
*
|
|
83
|
+
* A new `currentImageName` is the host asking for a particular image, so it
|
|
84
|
+
* wins. A new `images` array on its own isn't: a host that builds its list
|
|
85
|
+
* in a getter hands over a fresh array on every render, which says nothing
|
|
86
|
+
* about the images having changed. So the viewer holds its place by name and
|
|
87
|
+
* only goes back to the start when the image it was showing is really gone.
|
|
88
|
+
*/
|
|
89
|
+
indexToShow(changed, previousImages) {
|
|
90
|
+
if (changed.has('currentImageName') && this.currentImageName) {
|
|
91
|
+
const requested = this.images.findIndex((image) => image.name === this.currentImageName);
|
|
92
|
+
if (requested >= 0)
|
|
93
|
+
return requested;
|
|
94
|
+
}
|
|
95
|
+
const showing = previousImages?.[this.currentIndex]?.name;
|
|
96
|
+
if (showing) {
|
|
97
|
+
const stillThere = this.images.findIndex((image) => image.name === showing);
|
|
98
|
+
if (stillThere >= 0)
|
|
99
|
+
return stillThere;
|
|
100
|
+
}
|
|
101
|
+
const named = this.currentImageName
|
|
102
|
+
? this.images.findIndex((image) => image.name === this.currentImageName)
|
|
103
|
+
: -1;
|
|
104
|
+
return named >= 0 ? named : 0;
|
|
105
|
+
}
|
|
82
106
|
render() {
|
|
83
107
|
if (this.images.length === 0)
|
|
84
108
|
return nothing;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-image-viewer.js","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-image-viewer.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,GAAG,EAA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IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2B;AAGhC;IAArB,KAAK,CAAC,aAAa,CAAC;gDAAyB;AAGvB;IAAtB,KAAK,CAAC,cAAc,CAAC;iDAA0B;AAGvC;IAAR,KAAK,EAAE;mDAAkB;AAET;IAAhB,KAAK,EAAE;gDAA2B;AAOlB;IAAhB,KAAK,EAAE;sDAA6B;AAGpB;IAAhB,KAAK,EAAE;+CAA0C;AA5BvC,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAygBzB","sourcesContent":["import {\n css,\n type CSSResultGroup,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { keyed } from 'lit/directives/keyed.js';\nimport { msg, str } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { prefersReducedMotion } from '@src/util/prefers-reduced-motion';\nimport { ImageViewerGestures } from './image-viewer-gestures';\nimport type { ImageViewerImage, SlideDirection, WrapEdge } from './models';\nimport type { IAImageViewerSlide } from './ia-imgview-slide';\nimport './ia-imgview-slide';\nimport './ia-imgview-controls';\n\n/** Detail carried by the load and failure events a slide reports. */\ntype SlideImageEvent = CustomEvent<{ image: ImageViewerImage }>;\n\n/**\n * A swipeable image carousel.\n *\n * Shows one image at a time from a list, with previous/next buttons, a\n * counter, keyboard arrows, horizontal wheel scrolling and touch swipes.\n * Clicking an image opens it in a new tab.\n *\n * The viewer holds no opinion about where the images came from: it takes a\n * plain list of names and URLs, and reports the image it lands on through\n * `imageChanged` so a host can mirror that into its own URL or analytics.\n *\n * @fires imageChanged - The viewer settled on a new image.\n * @fires imageLoaded - An image the viewer showed finished loading.\n * @fires imageLoadFailed - An image the viewer showed could not be loaded.\n * Fires once per image until it loads successfully or the set changes.\n * @fires imageActivated - An image was clicked. Cancelable: preventing it\n * stops the default of opening the image in a new tab.\n */\n@customElement('ia-image-viewer')\nexport class IAImageViewer extends LitElement {\n @property({ type: Array }) images: ImageViewerImage[] = [];\n\n /**\n * Name of the image to show. Changing it jumps straight to that image\n * without animating. An unknown name shows the first image.\n */\n @property({ type: String }) currentImageName?: string;\n\n /** Read by the gesture controller, which tracks touches against it. */\n @query('.image-area') imageArea?: HTMLElement;\n\n /** Read by the gesture controller, which translates it during a drag. */\n @query('.slide-track') slideTrack?: HTMLElement;\n\n /** Read by the gesture controller to navigate relative to the current image. */\n @state() currentIndex = 0;\n\n @state() private animating = false;\n\n /**\n * Incremented when an animation is interrupted to force the track element to\n * be recreated via the `keyed()` directive, which guarantees the CSS\n * animation restarts even if the direction is the same.\n */\n @state() private slideGeneration = 0;\n\n /** Which edge just wrapped, if any. Drives the glow indicator. */\n @state() private wrapEdge: WrapEdge | null = null;\n\n /**\n * Images already reported as failed, so a broken image isn't counted again\n * every time the viewer passes over it. Navigating back re-fires `error` on\n * the recreated element, and the neighbouring slides staged during an\n * animation or a drag load the same image too, so without this a single\n * broken derivative reports several times a session.\n *\n * Cleared when the image set changes, which is the point a name stops\n * standing for the same file.\n */\n private reportedFailures = new Set<string>();\n\n private slideTarget: number | null = null;\n\n private slideDirection: SlideDirection | null = null;\n\n private gestures = new ImageViewerGestures(this);\n\n get imageCount(): number {\n return this.images.length;\n }\n\n /** The image currently on screen, if there is one. */\n get currentImage(): ImageViewerImage | undefined {\n return this.images[this.currentIndex];\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('images') || changed.has('currentImageName')) {\n const requested = this.currentImageName\n ? this.images.findIndex((i) => i.name === this.currentImageName)\n : -1;\n this.currentIndex = requested >= 0 ? requested : 0;\n\n this.animating = false;\n this.slideGeneration = 0;\n this.slideTarget = null;\n this.slideDirection = null;\n this.wrapEdge = null;\n this.reportedFailures.clear();\n this.preloadAdjacentImages();\n }\n }\n\n render(): TemplateResult | typeof nothing {\n if (this.images.length === 0) return nothing;\n\n const { dragging } = this.gestures;\n const current = this.images[this.currentIndex];\n const showControls = this.images.length > 1;\n\n const trackClasses = {\n 'slide-track': true,\n 'sliding-next':\n this.animating && !dragging && this.slideDirection === 'next',\n 'sliding-prev':\n this.animating && !dragging && this.slideDirection === 'prev',\n dragging,\n };\n\n const prevIndex =\n (this.currentIndex - 1 + this.images.length) % this.images.length;\n const nextIndex = (this.currentIndex + 1) % this.images.length;\n\n const slideTarget =\n this.animating && !dragging && this.slideTarget !== null\n ? this.images[this.slideTarget]\n : null;\n const prevImage = dragging ? this.images[prevIndex] : slideTarget;\n const nextImage = dragging ? this.images[nextIndex] : slideTarget;\n const showPrev =\n dragging || (slideTarget !== null && this.slideDirection === 'prev');\n const showNext =\n dragging || (slideTarget !== null && this.slideDirection === 'next');\n\n const displayIndex =\n this.animating && this.slideTarget !== null\n ? this.slideTarget\n : this.currentIndex;\n\n return html`\n <div class=\"viewer\">\n <div class=\"image-area\">\n ${this.wrapEdge\n ? html`<div\n class=\"wrap-glow ${this.wrapEdge === 'start'\n ? 'glow-start'\n : 'glow-end'}\"\n @animationend=${this.onWrapGlowEnd}\n ></div>`\n : nothing}\n ${keyed(\n this.slideGeneration,\n html`<div\n class=${classMap(trackClasses)}\n @animationend=${this.onSlideEnd}\n @imageLoaded=${this.onImageLoaded}\n @imageFailed=${this.onImageFailed}\n @imageActivated=${this.onImageActivated}\n >\n ${showPrev && prevImage ? this.slideTemplate(prevImage) : nothing}\n ${this.slideTemplate(current)}\n ${showNext && nextImage ? this.slideTemplate(nextImage) : nothing}\n </div>`,\n )}\n </div>\n ${showControls\n ? html`\n <ia-imgview-controls\n .currentIndex=${displayIndex}\n .totalImages=${this.images.length}\n @showPrevious=${this.showPrevious}\n @showNext=${this.showNext}\n ></ia-imgview-controls>\n `\n : nothing}\n ${this.announcementTemplate}\n </div>\n `;\n }\n\n private slideTemplate(image: ImageViewerImage): TemplateResult {\n return html`<ia-imgview-slide .image=${image}></ia-imgview-slide>`;\n }\n\n /**\n * Announces the image to a screen reader, which otherwise gets nothing when\n * the counter and the picture change under it.\n */\n private get announcementTemplate(): TemplateResult {\n const current = this.images[this.currentIndex];\n const position = msg(\n str`Image ${this.currentIndex + 1} of ${this.images.length}`,\n );\n const label = current?.title ?? current?.name;\n return html`\n <div class=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n ${label ? `${position}: ${label}` : position}\n </div>\n `;\n }\n\n /**\n * Passes a slide's load result on to the host, which is where reporting\n * belongs. The slide's own events stop at this shadow root, so they're\n * re-dispatched rather than allowed to escape.\n */\n private onImageLoaded(e: SlideImageEvent): void {\n // A load that succeeds clears the failure, so an image that breaks again\n // later is reported again rather than swallowed as a repeat.\n this.reportedFailures.delete(e.detail.image.name);\n this.dispatchEvent(\n new CustomEvent('imageLoaded', { detail: { image: e.detail.image } }),\n );\n }\n\n private onImageFailed(e: SlideImageEvent): void {\n const { image } = e.detail;\n if (this.reportedFailures.has(image.name)) return;\n this.reportedFailures.add(image.name);\n this.dispatchEvent(\n new CustomEvent('imageLoadFailed', { detail: { image } }),\n );\n }\n\n /**\n * Decides whether a click on a slide opens the image.\n *\n * Two things can stop it: the click is the tail end of a swipe, or the host\n * cancels the event to show the image its own way. The slide's event doesn't\n * cross this shadow root, so it's re-raised here for the host to see, and a\n * veto is passed back down to cancel the click.\n */\n private onImageActivated(e: SlideImageEvent): void {\n if (this.gestures.consumeSwipeTap()) {\n e.preventDefault();\n return;\n }\n const allowed = this.dispatchEvent(\n new CustomEvent('imageActivated', {\n detail: { image: e.detail.image },\n cancelable: true,\n }),\n );\n if (!allowed) e.preventDefault();\n }\n\n /**\n * Inserts the neighbouring slides around the current one so the touch target\n * element stays in the DOM (avoiding touchcancel). These aren't rendered\n * from the template, so they're marked for the gesture controller to clean\n * up. The dragging class shifts the track to centre on the middle slide.\n */\n insertDragSlides(): void {\n const track = this.slideTrack;\n if (!track) return;\n const prevIdx =\n (this.currentIndex - 1 + this.images.length) % this.images.length;\n const nextIdx = (this.currentIndex + 1) % this.images.length;\n\n track.insertBefore(\n this.createDragSlide(this.images[prevIdx]),\n track.firstChild,\n );\n track.appendChild(this.createDragSlide(this.images[nextIdx]));\n\n track.classList.add('dragging');\n }\n\n removeDragSlides(): void {\n const track = this.slideTrack;\n if (!track) return;\n track.querySelectorAll('[data-drag-slide]').forEach((el) => el.remove());\n track.classList.remove('dragging');\n }\n\n private createDragSlide(image: ImageViewerImage): IAImageViewerSlide {\n const slide = document.createElement('ia-imgview-slide');\n slide.image = image;\n slide.dataset.dragSlide = '';\n return slide;\n }\n\n showNext(): void {\n this.settleIfAnimating();\n this.moveTo((this.currentIndex + 1) % this.images.length, 'next');\n }\n\n showPrevious(): void {\n this.settleIfAnimating();\n this.moveTo(\n (this.currentIndex - 1 + this.images.length) % this.images.length,\n 'prev',\n );\n }\n\n /**\n * Starts the move to another image. With reduced motion there's no animation\n * to wait on, so the move lands immediately: nothing would fire the\n * `animationend` that otherwise commits it.\n */\n private moveTo(target: number, direction: SlideDirection): void {\n const wraps =\n direction === 'next'\n ? this.currentIndex === this.images.length - 1\n : this.currentIndex === 0;\n this.preloadAroundIndex(target);\n\n if (prefersReducedMotion()) {\n this.currentIndex = target;\n this.settleAtCurrentIndex();\n return;\n }\n\n this.slideTarget = target;\n this.slideDirection = direction;\n this.animating = true;\n this.wrapEdge = wraps ? (direction === 'next' ? 'end' : 'start') : null;\n }\n\n /**\n * Moves to the image a completed drag landed on. The drag has already\n * animated the track there, so this only updates state.\n */\n commitDrag(direction: SlideDirection): void {\n const wraps =\n direction === 'next'\n ? this.currentIndex === this.images.length - 1\n : this.currentIndex === 0;\n const step = direction === 'next' ? 1 : -1;\n this.currentIndex =\n (this.currentIndex + step + this.images.length) % this.images.length;\n if (wraps && !prefersReducedMotion()) {\n this.wrapEdge = direction === 'next' ? 'end' : 'start';\n }\n this.emitImageChanged();\n }\n\n /**\n * If an animation is in progress, immediately commit its target so the next\n * animation starts from the right position. Bumps the generation key to\n * force the track element to be recreated, which restarts the CSS animation.\n */\n settleIfAnimating(): void {\n if (!this.animating || this.slideTarget === null) return;\n this.currentIndex = this.slideTarget;\n this.slideGeneration++;\n }\n\n private onWrapGlowEnd(): void {\n this.wrapEdge = null;\n }\n\n private onSlideEnd(): void {\n if (this.slideTarget === null) return;\n this.currentIndex = this.slideTarget;\n this.settleAtCurrentIndex();\n }\n\n /** Finishes a move, however it was driven. */\n private settleAtCurrentIndex(): void {\n this.slideTarget = null;\n this.slideDirection = null;\n this.animating = false;\n this.gestures.animationSettled();\n this.emitImageChanged();\n this.preloadAdjacentImages();\n }\n\n private emitImageChanged(): void {\n const image = this.images[this.currentIndex];\n if (!image) return;\n this.dispatchEvent(\n new CustomEvent('imageChanged', {\n detail: { image, index: this.currentIndex },\n }),\n );\n }\n\n /**\n * Preloads the next and previous images around `currentIndex` so the first\n * navigation feels instant.\n */\n private preloadAdjacentImages(): void {\n this.preloadAroundIndex(this.currentIndex);\n }\n\n /**\n * Preloads images adjacent to the given index. Called both at rest (around\n * `currentIndex`) and at the start of a move (around the target) so rapid\n * navigation stays ahead of the browser cache.\n *\n * A preload that fails is deliberately not reported. These requests are\n * speculative and the viewer may never show them, so counting them would\n * inflate the failure rate with images nobody looked at. Navigating to a\n * broken image renders a real slide, whose `error` reports it then.\n */\n preloadAroundIndex(index: number): void {\n if (this.images.length <= 1) return;\n const next = (index + 1) % this.images.length;\n const prev = (index - 1 + this.images.length) % this.images.length;\n for (const idx of [next, prev]) {\n const img = new Image();\n img.src = this.images[idx].url;\n }\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --image-viewer-height--: var(--image-viewer-height, 100%);\n --image-viewer-max-width--: var(--image-viewer-max-width, none);\n --image-viewer-slide-duration--: var(\n --image-viewer-slide-duration,\n 500ms\n );\n --image-viewer-glow-color--: var(\n --image-viewer-glow-color,\n rgba(255, 255, 255, 0.25)\n );\n --image-viewer-glow-width--: var(--image-viewer-glow-width, 100px);\n /*\n * The breakpoint the controls query against. Named so the query in\n * ia-imgview-controls resolves to this host rather than to whatever\n * container the consumer happens to have further up.\n */\n container: image-viewer / inline-size;\n\n display: block;\n height: var(--image-viewer-height--);\n max-width: var(--image-viewer-max-width--);\n margin: 0 auto;\n }\n\n .viewer {\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n\n .image-area {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n touch-action: pan-y pinch-zoom;\n }\n\n .wrap-glow {\n position: absolute;\n top: 0;\n bottom: 0;\n width: var(--image-viewer-glow-width--);\n pointer-events: none;\n z-index: 2;\n animation: glow-fade 700ms ease-out both;\n }\n\n .glow-start {\n left: 0;\n background: linear-gradient(\n to right,\n var(--image-viewer-glow-color--),\n transparent\n );\n }\n\n .glow-end {\n right: 0;\n background: linear-gradient(\n to left,\n var(--image-viewer-glow-color--),\n transparent\n );\n }\n\n @keyframes glow-fade {\n 0% {\n opacity: 0;\n }\n 20% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n .slide-track {\n display: flex;\n width: 100%;\n height: 100%;\n flex-shrink: 0;\n }\n\n @keyframes slide-next {\n from {\n transform: translateX(0);\n }\n to {\n transform: translateX(-100%);\n }\n }\n\n @keyframes slide-prev {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(0);\n }\n }\n\n .slide-track.dragging {\n transform: translateX(-100%);\n }\n\n .slide-track.sliding-next {\n animation: slide-next var(--image-viewer-slide-duration--) ease-in-out\n both;\n }\n\n .slide-track.sliding-prev {\n animation: slide-prev var(--image-viewer-slide-duration--) ease-in-out\n both;\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n border: 0;\n overflow: hidden;\n white-space: nowrap;\n clip-path: inset(50%);\n }\n `,\n ];\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ia-image-viewer': IAImageViewer;\n }\n}\n"]}
|
|
1
|
+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,CAAC;uDAA2B;AAGhC;IAArB,KAAK,CAAC,aAAa,CAAC;gDAAyB;AAGvB;IAAtB,KAAK,CAAC,cAAc,CAAC;iDAA0B;AAGvC;IAAR,KAAK,EAAE;mDAAkB;AAET;IAAhB,KAAK,EAAE;gDAA2B;AAOlB;IAAhB,KAAK,EAAE;sDAA6B;AAGpB;IAAhB,KAAK,EAAE;+CAA0C;AA5BvC,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA2iBzB","sourcesContent":["import {\n css,\n type CSSResultGroup,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { keyed } from 'lit/directives/keyed.js';\nimport { msg, str } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { prefersReducedMotion } from '@src/util/prefers-reduced-motion';\nimport { ImageViewerGestures } from './image-viewer-gestures';\nimport type { ImageViewerImage, SlideDirection, WrapEdge } from './models';\nimport type { IAImageViewerSlide } from './ia-imgview-slide';\nimport './ia-imgview-slide';\nimport './ia-imgview-controls';\n\n/** Detail carried by the load and failure events a slide reports. */\ntype SlideImageEvent = CustomEvent<{ image: ImageViewerImage }>;\n\n/**\n * A swipeable image carousel.\n *\n * Shows one image at a time from a list, with previous/next buttons, a\n * counter, keyboard arrows, horizontal wheel scrolling and touch swipes.\n * Clicking an image opens it in a new tab.\n *\n * The viewer holds no opinion about where the images came from: it takes a\n * plain list of names and URLs, and reports the image it lands on through\n * `imageChanged` so a host can mirror that into its own URL or analytics.\n *\n * @fires imageChanged - The viewer settled on a new image.\n * @fires imageLoaded - An image the viewer showed finished loading.\n * @fires imageLoadFailed - An image the viewer showed could not be loaded.\n * Fires once per image until it loads successfully or the set changes.\n * @fires imageActivated - An image was clicked. Cancelable: preventing it\n * stops the default of opening the image in a new tab.\n */\n@customElement('ia-image-viewer')\nexport class IAImageViewer extends LitElement {\n @property({ type: Array }) images: ImageViewerImage[] = [];\n\n /**\n * Name of the image to show. Changing it jumps straight to that image\n * without animating. An unknown name shows the first image.\n */\n @property({ type: String }) currentImageName?: string;\n\n /** Read by the gesture controller, which tracks touches against it. */\n @query('.image-area') imageArea?: HTMLElement;\n\n /** Read by the gesture controller, which translates it during a drag. */\n @query('.slide-track') slideTrack?: HTMLElement;\n\n /** Read by the gesture controller to navigate relative to the current image. */\n @state() currentIndex = 0;\n\n @state() private animating = false;\n\n /**\n * Incremented when an animation is interrupted to force the track element to\n * be recreated via the `keyed()` directive, which guarantees the CSS\n * animation restarts even if the direction is the same.\n */\n @state() private slideGeneration = 0;\n\n /** Which edge just wrapped, if any. Drives the glow indicator. */\n @state() private wrapEdge: WrapEdge | null = null;\n\n /**\n * Images already reported as failed, so a broken image isn't counted again\n * every time the viewer passes over it. Navigating back re-fires `error` on\n * the recreated element, and the neighbouring slides staged during an\n * animation or a drag load the same image too, so without this a single\n * broken derivative reports several times a session.\n *\n * Cleared when the image set changes, which is the point a name stops\n * standing for the same file.\n */\n private reportedFailures = new Set<string>();\n\n private slideTarget: number | null = null;\n\n private slideDirection: SlideDirection | null = null;\n\n private gestures = new ImageViewerGestures(this);\n\n get imageCount(): number {\n return this.images.length;\n }\n\n /** The image currently on screen, if there is one. */\n get currentImage(): ImageViewerImage | undefined {\n return this.images[this.currentIndex];\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('images') || changed.has('currentImageName')) {\n const previous = changed.get('images') as ImageViewerImage[] | undefined;\n this.currentIndex = this.indexToShow(changed, previous);\n\n this.animating = false;\n this.slideGeneration = 0;\n this.slideTarget = null;\n this.slideDirection = null;\n this.wrapEdge = null;\n this.reportedFailures.clear();\n this.preloadAdjacentImages();\n }\n }\n\n /**\n * Where to land when the images or the requested name change.\n *\n * A new `currentImageName` is the host asking for a particular image, so it\n * wins. A new `images` array on its own isn't: a host that builds its list\n * in a getter hands over a fresh array on every render, which says nothing\n * about the images having changed. So the viewer holds its place by name and\n * only goes back to the start when the image it was showing is really gone.\n */\n private indexToShow(\n changed: PropertyValues,\n previousImages: ImageViewerImage[] | undefined,\n ): number {\n if (changed.has('currentImageName') && this.currentImageName) {\n const requested = this.images.findIndex(\n (image) => image.name === this.currentImageName,\n );\n if (requested >= 0) return requested;\n }\n\n const showing = previousImages?.[this.currentIndex]?.name;\n if (showing) {\n const stillThere = this.images.findIndex(\n (image) => image.name === showing,\n );\n if (stillThere >= 0) return stillThere;\n }\n\n const named = this.currentImageName\n ? this.images.findIndex((image) => image.name === this.currentImageName)\n : -1;\n return named >= 0 ? named : 0;\n }\n\n render(): TemplateResult | typeof nothing {\n if (this.images.length === 0) return nothing;\n\n const { dragging } = this.gestures;\n const current = this.images[this.currentIndex];\n const showControls = this.images.length > 1;\n\n const trackClasses = {\n 'slide-track': true,\n 'sliding-next':\n this.animating && !dragging && this.slideDirection === 'next',\n 'sliding-prev':\n this.animating && !dragging && this.slideDirection === 'prev',\n dragging,\n };\n\n const prevIndex =\n (this.currentIndex - 1 + this.images.length) % this.images.length;\n const nextIndex = (this.currentIndex + 1) % this.images.length;\n\n const slideTarget =\n this.animating && !dragging && this.slideTarget !== null\n ? this.images[this.slideTarget]\n : null;\n const prevImage = dragging ? this.images[prevIndex] : slideTarget;\n const nextImage = dragging ? this.images[nextIndex] : slideTarget;\n const showPrev =\n dragging || (slideTarget !== null && this.slideDirection === 'prev');\n const showNext =\n dragging || (slideTarget !== null && this.slideDirection === 'next');\n\n const displayIndex =\n this.animating && this.slideTarget !== null\n ? this.slideTarget\n : this.currentIndex;\n\n return html`\n <div class=\"viewer\">\n <div class=\"image-area\">\n ${this.wrapEdge\n ? html`<div\n class=\"wrap-glow ${this.wrapEdge === 'start'\n ? 'glow-start'\n : 'glow-end'}\"\n @animationend=${this.onWrapGlowEnd}\n ></div>`\n : nothing}\n ${keyed(\n this.slideGeneration,\n html`<div\n class=${classMap(trackClasses)}\n @animationend=${this.onSlideEnd}\n @imageLoaded=${this.onImageLoaded}\n @imageFailed=${this.onImageFailed}\n @imageActivated=${this.onImageActivated}\n >\n ${showPrev && prevImage ? this.slideTemplate(prevImage) : nothing}\n ${this.slideTemplate(current)}\n ${showNext && nextImage ? this.slideTemplate(nextImage) : nothing}\n </div>`,\n )}\n </div>\n ${showControls\n ? html`\n <ia-imgview-controls\n .currentIndex=${displayIndex}\n .totalImages=${this.images.length}\n @showPrevious=${this.showPrevious}\n @showNext=${this.showNext}\n ></ia-imgview-controls>\n `\n : nothing}\n ${this.announcementTemplate}\n </div>\n `;\n }\n\n private slideTemplate(image: ImageViewerImage): TemplateResult {\n return html`<ia-imgview-slide .image=${image}></ia-imgview-slide>`;\n }\n\n /**\n * Announces the image to a screen reader, which otherwise gets nothing when\n * the counter and the picture change under it.\n */\n private get announcementTemplate(): TemplateResult {\n const current = this.images[this.currentIndex];\n const position = msg(\n str`Image ${this.currentIndex + 1} of ${this.images.length}`,\n );\n const label = current?.title ?? current?.name;\n return html`\n <div class=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n ${label ? `${position}: ${label}` : position}\n </div>\n `;\n }\n\n /**\n * Passes a slide's load result on to the host, which is where reporting\n * belongs. The slide's own events stop at this shadow root, so they're\n * re-dispatched rather than allowed to escape.\n */\n private onImageLoaded(e: SlideImageEvent): void {\n // A load that succeeds clears the failure, so an image that breaks again\n // later is reported again rather than swallowed as a repeat.\n this.reportedFailures.delete(e.detail.image.name);\n this.dispatchEvent(\n new CustomEvent('imageLoaded', { detail: { image: e.detail.image } }),\n );\n }\n\n private onImageFailed(e: SlideImageEvent): void {\n const { image } = e.detail;\n if (this.reportedFailures.has(image.name)) return;\n this.reportedFailures.add(image.name);\n this.dispatchEvent(\n new CustomEvent('imageLoadFailed', { detail: { image } }),\n );\n }\n\n /**\n * Decides whether a click on a slide opens the image.\n *\n * Two things can stop it: the click is the tail end of a swipe, or the host\n * cancels the event to show the image its own way. The slide's event doesn't\n * cross this shadow root, so it's re-raised here for the host to see, and a\n * veto is passed back down to cancel the click.\n */\n private onImageActivated(e: SlideImageEvent): void {\n if (this.gestures.consumeSwipeTap()) {\n e.preventDefault();\n return;\n }\n const allowed = this.dispatchEvent(\n new CustomEvent('imageActivated', {\n detail: { image: e.detail.image },\n cancelable: true,\n }),\n );\n if (!allowed) e.preventDefault();\n }\n\n /**\n * Inserts the neighbouring slides around the current one so the touch target\n * element stays in the DOM (avoiding touchcancel). These aren't rendered\n * from the template, so they're marked for the gesture controller to clean\n * up. The dragging class shifts the track to centre on the middle slide.\n */\n insertDragSlides(): void {\n const track = this.slideTrack;\n if (!track) return;\n const prevIdx =\n (this.currentIndex - 1 + this.images.length) % this.images.length;\n const nextIdx = (this.currentIndex + 1) % this.images.length;\n\n track.insertBefore(\n this.createDragSlide(this.images[prevIdx]),\n track.firstChild,\n );\n track.appendChild(this.createDragSlide(this.images[nextIdx]));\n\n track.classList.add('dragging');\n }\n\n removeDragSlides(): void {\n const track = this.slideTrack;\n if (!track) return;\n track.querySelectorAll('[data-drag-slide]').forEach((el) => el.remove());\n track.classList.remove('dragging');\n }\n\n private createDragSlide(image: ImageViewerImage): IAImageViewerSlide {\n const slide = document.createElement(\n 'ia-imgview-slide',\n ) as IAImageViewerSlide;\n slide.image = image;\n slide.dataset.dragSlide = '';\n return slide;\n }\n\n showNext(): void {\n this.settleIfAnimating();\n this.moveTo((this.currentIndex + 1) % this.images.length, 'next');\n }\n\n showPrevious(): void {\n this.settleIfAnimating();\n this.moveTo(\n (this.currentIndex - 1 + this.images.length) % this.images.length,\n 'prev',\n );\n }\n\n /**\n * Starts the move to another image. With reduced motion there's no animation\n * to wait on, so the move lands immediately: nothing would fire the\n * `animationend` that otherwise commits it.\n */\n private moveTo(target: number, direction: SlideDirection): void {\n const wraps =\n direction === 'next'\n ? this.currentIndex === this.images.length - 1\n : this.currentIndex === 0;\n this.preloadAroundIndex(target);\n\n if (prefersReducedMotion()) {\n this.currentIndex = target;\n this.settleAtCurrentIndex();\n return;\n }\n\n this.slideTarget = target;\n this.slideDirection = direction;\n this.animating = true;\n this.wrapEdge = wraps ? (direction === 'next' ? 'end' : 'start') : null;\n }\n\n /**\n * Moves to the image a completed drag landed on. The drag has already\n * animated the track there, so this only updates state.\n */\n commitDrag(direction: SlideDirection): void {\n const wraps =\n direction === 'next'\n ? this.currentIndex === this.images.length - 1\n : this.currentIndex === 0;\n const step = direction === 'next' ? 1 : -1;\n this.currentIndex =\n (this.currentIndex + step + this.images.length) % this.images.length;\n if (wraps && !prefersReducedMotion()) {\n this.wrapEdge = direction === 'next' ? 'end' : 'start';\n }\n this.emitImageChanged();\n }\n\n /**\n * If an animation is in progress, immediately commit its target so the next\n * animation starts from the right position. Bumps the generation key to\n * force the track element to be recreated, which restarts the CSS animation.\n */\n settleIfAnimating(): void {\n if (!this.animating || this.slideTarget === null) return;\n this.currentIndex = this.slideTarget;\n this.slideGeneration++;\n }\n\n private onWrapGlowEnd(): void {\n this.wrapEdge = null;\n }\n\n private onSlideEnd(): void {\n if (this.slideTarget === null) return;\n this.currentIndex = this.slideTarget;\n this.settleAtCurrentIndex();\n }\n\n /** Finishes a move, however it was driven. */\n private settleAtCurrentIndex(): void {\n this.slideTarget = null;\n this.slideDirection = null;\n this.animating = false;\n this.gestures.animationSettled();\n this.emitImageChanged();\n this.preloadAdjacentImages();\n }\n\n private emitImageChanged(): void {\n const image = this.images[this.currentIndex];\n if (!image) return;\n this.dispatchEvent(\n new CustomEvent('imageChanged', {\n detail: { image, index: this.currentIndex },\n }),\n );\n }\n\n /**\n * Preloads the next and previous images around `currentIndex` so the first\n * navigation feels instant.\n */\n private preloadAdjacentImages(): void {\n this.preloadAroundIndex(this.currentIndex);\n }\n\n /**\n * Preloads images adjacent to the given index. Called both at rest (around\n * `currentIndex`) and at the start of a move (around the target) so rapid\n * navigation stays ahead of the browser cache.\n *\n * A preload that fails is deliberately not reported. These requests are\n * speculative and the viewer may never show them, so counting them would\n * inflate the failure rate with images nobody looked at. Navigating to a\n * broken image renders a real slide, whose `error` reports it then.\n */\n preloadAroundIndex(index: number): void {\n if (this.images.length <= 1) return;\n const next = (index + 1) % this.images.length;\n const prev = (index - 1 + this.images.length) % this.images.length;\n for (const idx of [next, prev]) {\n const img = new Image();\n img.src = this.images[idx].url;\n }\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --image-viewer-height--: var(--image-viewer-height, 100%);\n --image-viewer-max-width--: var(--image-viewer-max-width, none);\n --image-viewer-slide-duration--: var(\n --image-viewer-slide-duration,\n 500ms\n );\n --image-viewer-glow-color--: var(\n --image-viewer-glow-color,\n rgba(255, 255, 255, 0.25)\n );\n --image-viewer-glow-width--: var(--image-viewer-glow-width, 100px);\n /*\n * The breakpoint the controls query against. Named so the query in\n * ia-imgview-controls resolves to this host rather than to whatever\n * container the consumer happens to have further up.\n */\n container: image-viewer / inline-size;\n\n display: block;\n height: var(--image-viewer-height--);\n max-width: var(--image-viewer-max-width--);\n margin: 0 auto;\n }\n\n .viewer {\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n\n .image-area {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n touch-action: pan-y pinch-zoom;\n }\n\n .wrap-glow {\n position: absolute;\n top: 0;\n bottom: 0;\n width: var(--image-viewer-glow-width--);\n pointer-events: none;\n z-index: 2;\n animation: glow-fade 700ms ease-out both;\n }\n\n .glow-start {\n left: 0;\n background: linear-gradient(\n to right,\n var(--image-viewer-glow-color--),\n transparent\n );\n }\n\n .glow-end {\n right: 0;\n background: linear-gradient(\n to left,\n var(--image-viewer-glow-color--),\n transparent\n );\n }\n\n @keyframes glow-fade {\n 0% {\n opacity: 0;\n }\n 20% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n .slide-track {\n display: flex;\n width: 100%;\n height: 100%;\n flex-shrink: 0;\n }\n\n @keyframes slide-next {\n from {\n transform: translateX(0);\n }\n to {\n transform: translateX(-100%);\n }\n }\n\n @keyframes slide-prev {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(0);\n }\n }\n\n .slide-track.dragging {\n transform: translateX(-100%);\n }\n\n .slide-track.sliding-next {\n animation: slide-next var(--image-viewer-slide-duration--) ease-in-out\n both;\n }\n\n .slide-track.sliding-prev {\n animation: slide-prev var(--image-viewer-slide-duration--) ease-in-out\n both;\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n border: 0;\n overflow: hidden;\n white-space: nowrap;\n clip-path: inset(50%);\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -19,9 +19,4 @@ export declare class IAImageViewerControls extends LitElement {
|
|
|
19
19
|
private onNext;
|
|
20
20
|
static get styles(): CSSResultGroup;
|
|
21
21
|
}
|
|
22
|
-
declare global {
|
|
23
|
-
interface HTMLElementTagNameMap {
|
|
24
|
-
'ia-imgview-controls': IAImageViewerControls;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
22
|
//# sourceMappingURL=ia-imgview-controls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-imgview-controls.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-imgview-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,UAAU,EACV,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAMb;;;;;;;;;;GAUG;AACH,qBACa,qBAAsB,SAAQ,UAAU;IACnD,kEAAkE;IACtC,YAAY,SAAK;IAEjB,WAAW,SAAK;IAE5C,MAAM,IAAI,cAAc;IAoBxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,MAAM;IAId,MAAM,KAAK,MAAM,IAAI,cAAc,CAgGlC;CACF
|
|
1
|
+
{"version":3,"file":"ia-imgview-controls.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-imgview-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,UAAU,EACV,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAMb;;;;;;;;;;GAUG;AACH,qBACa,qBAAsB,SAAQ,UAAU;IACnD,kEAAkE;IACtC,YAAY,SAAK;IAEjB,WAAW,SAAK;IAE5C,MAAM,IAAI,cAAc;IAoBxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,MAAM;IAId,MAAM,KAAK,MAAM,IAAI,cAAc,CAgGlC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-imgview-controls.js","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-imgview-controls.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,GAEX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD;;;;;;;;;;GAUG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;QACL,kEAAkE;QACtC,iBAAY,GAAG,CAAC,CAAC;QAEjB,gBAAW,GAAG,CAAC,CAAC;IA+H9C,CAAC;IA7HC,MAAM;QACJ,OAAO,IAAI,CAAA;;;qBAGM,GAAG,CAAC,gBAAgB,CAAC;iBACzB,IAAI,CAAC,UAAU;;;;6BAIH,IAAI,CAAC,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW;;;qBAGnD,GAAG,CAAC,YAAY,CAAC;iBACrB,IAAI,CAAC,MAAM;;;;KAIvB,CAAC;IACJ,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;IACtD,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2FF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjI6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAkB;AAEjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAiB;AAJjC,qBAAqB;IADjC,aAAa,CAAC,qBAAqB,CAAC;GACxB,qBAAqB,CAmIjC","sourcesContent":["import {\n css,\n type CSSResultGroup,\n html,\n LitElement,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * The image viewer's previous / next buttons and the \"n / total\" counter.\n *\n * Past the wide breakpoint the buttons position themselves over the image\n * area, which lives in the viewer's shadow root. That works because an\n * absolutely positioned element finds its containing block through the flat\n * tree, so the viewer's frame is still the reference as long as this element's\n * own host box stays unpositioned. The breakpoint queries the `image-viewer`\n * container by name, so it tracks the viewer's width rather than whichever\n * container a consumer happens to have further up the tree.\n */\n@customElement('ia-imgview-controls')\nexport class IAImageViewerControls extends LitElement {\n /** Zero-based index of the image being shown, for the counter. */\n @property({ type: Number }) currentIndex = 0;\n\n @property({ type: Number }) totalImages = 0;\n\n render(): TemplateResult {\n return html`\n <button\n class=\"nav-btn prev\"\n aria-label=${msg('Previous image')}\n @click=${this.onPrevious}\n >\n ‹\n </button>\n <div class=\"counter\">${this.currentIndex + 1} / ${this.totalImages}</div>\n <button\n class=\"nav-btn next\"\n aria-label=${msg('Next image')}\n @click=${this.onNext}\n >\n ›\n </button>\n `;\n }\n\n private onPrevious(): void {\n this.dispatchEvent(new CustomEvent('showPrevious'));\n }\n\n private onNext(): void {\n this.dispatchEvent(new CustomEvent('showNext'));\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --imgview-controls-text-color--: var(\n --image-viewer-text-color,\n var(--true-white)\n );\n --imgview-controls-btn-width--: var(\n --image-viewer-nav-button-width,\n 40px\n );\n --imgview-controls-btn-width-wide--: var(\n --image-viewer-nav-button-width-wide,\n 60px\n );\n --imgview-controls-focus-color--: var(\n --image-viewer-focus-outline-color,\n rgba(255, 255, 255, 0.8)\n );\n\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n margin-top: 0.8rem;\n }\n\n .nav-btn {\n width: var(--imgview-controls-btn-width--);\n background: transparent;\n color: var(--imgview-controls-text-color--);\n border: none;\n cursor: pointer;\n font-size: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.5;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);\n transition: opacity 0.15s;\n }\n\n .nav-btn:hover {\n opacity: 1;\n }\n\n .nav-btn:focus-visible {\n outline: 2px solid var(--imgview-controls-focus-color--);\n outline-offset: -2px;\n }\n\n .counter {\n color: var(--imgview-controls-text-color--);\n font-size: 14px;\n font-weight: 200;\n letter-spacing: 0.05em;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .nav-btn {\n transition: none;\n }\n }\n\n @container image-viewer (min-width: 890px) {\n :host {\n position: static;\n width: auto;\n margin-top: 0;\n }\n\n .nav-btn {\n position: absolute;\n top: 0;\n bottom: 0;\n width: var(--imgview-controls-btn-width-wide--);\n font-size: 60px;\n z-index: 1;\n }\n\n .prev {\n left: 0;\n }\n\n .next {\n right: 0;\n }\n\n .counter {\n margin-top: 0.8rem;\n }\n }\n `,\n ];\n }\n}\n
|
|
1
|
+
{"version":3,"file":"ia-imgview-controls.js","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/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;AAJjC,qBAAqB;IADjC,aAAa,CAAC,qBAAqB,CAAC;GACxB,qBAAqB,CAmIjC","sourcesContent":["import {\n css,\n type CSSResultGroup,\n html,\n LitElement,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * The image viewer's previous / next buttons and the \"n / total\" counter.\n *\n * Past the wide breakpoint the buttons position themselves over the image\n * area, which lives in the viewer's shadow root. That works because an\n * absolutely positioned element finds its containing block through the flat\n * tree, so the viewer's frame is still the reference as long as this element's\n * own host box stays unpositioned. The breakpoint queries the `image-viewer`\n * container by name, so it tracks the viewer's width rather than whichever\n * container a consumer happens to have further up the tree.\n */\n@customElement('ia-imgview-controls')\nexport class IAImageViewerControls extends LitElement {\n /** Zero-based index of the image being shown, for the counter. */\n @property({ type: Number }) currentIndex = 0;\n\n @property({ type: Number }) totalImages = 0;\n\n render(): TemplateResult {\n return html`\n <button\n class=\"nav-btn prev\"\n aria-label=${msg('Previous image')}\n @click=${this.onPrevious}\n >\n ‹\n </button>\n <div class=\"counter\">${this.currentIndex + 1} / ${this.totalImages}</div>\n <button\n class=\"nav-btn next\"\n aria-label=${msg('Next image')}\n @click=${this.onNext}\n >\n ›\n </button>\n `;\n }\n\n private onPrevious(): void {\n this.dispatchEvent(new CustomEvent('showPrevious'));\n }\n\n private onNext(): void {\n this.dispatchEvent(new CustomEvent('showNext'));\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --imgview-controls-text-color--: var(\n --image-viewer-text-color,\n var(--true-white)\n );\n --imgview-controls-btn-width--: var(\n --image-viewer-nav-button-width,\n 40px\n );\n --imgview-controls-btn-width-wide--: var(\n --image-viewer-nav-button-width-wide,\n 60px\n );\n --imgview-controls-focus-color--: var(\n --image-viewer-focus-outline-color,\n rgba(255, 255, 255, 0.8)\n );\n\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n margin-top: 0.8rem;\n }\n\n .nav-btn {\n width: var(--imgview-controls-btn-width--);\n background: transparent;\n color: var(--imgview-controls-text-color--);\n border: none;\n cursor: pointer;\n font-size: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.5;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);\n transition: opacity 0.15s;\n }\n\n .nav-btn:hover {\n opacity: 1;\n }\n\n .nav-btn:focus-visible {\n outline: 2px solid var(--imgview-controls-focus-color--);\n outline-offset: -2px;\n }\n\n .counter {\n color: var(--imgview-controls-text-color--);\n font-size: 14px;\n font-weight: 200;\n letter-spacing: 0.05em;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .nav-btn {\n transition: none;\n }\n }\n\n @container image-viewer (min-width: 890px) {\n :host {\n position: static;\n width: auto;\n margin-top: 0;\n }\n\n .nav-btn {\n position: absolute;\n top: 0;\n bottom: 0;\n width: var(--imgview-controls-btn-width-wide--);\n font-size: 60px;\n z-index: 1;\n }\n\n .prev {\n left: 0;\n }\n\n .next {\n right: 0;\n }\n\n .counter {\n margin-top: 0.8rem;\n }\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -41,9 +41,4 @@ export declare class IAImageViewerSlide extends LitElement {
|
|
|
41
41
|
private checkAlreadyResolved;
|
|
42
42
|
static get styles(): CSSResultGroup;
|
|
43
43
|
}
|
|
44
|
-
declare global {
|
|
45
|
-
interface HTMLElementTagNameMap {
|
|
46
|
-
'ia-imgview-slide': IAImageViewerSlide;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
44
|
//# sourceMappingURL=ia-imgview-slide.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-imgview-slide.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-imgview-slide.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,UAAU,EACV,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,M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,\n type CSSResultGroup,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { ImageViewerImage } from './models';\n\n/**\n * A single image in the viewer's track.\n *\n * Owns everything about one image: its load state, its failure message, and\n * the link that opens the full-size file. The viewer creates these both from\n * its template and by hand during a drag, so the element works with no\n * per-instance setup beyond its properties.\n */\n@customElement('ia-imgview-slide')\nexport class IAImageViewerSlide extends LitElement {\n @property({ type: Object }) image?: ImageViewerImage;\n\n @query('.main-image') private imageElement?: HTMLImageElement;\n\n @state() private loaded = false;\n\n @state() private failed = false;\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('image')) {\n this.loaded = false;\n this.failed = false;\n }\n }\n\n protected updated(): void {\n this.checkAlreadyResolved();\n }\n\n render(): TemplateResult | typeof nothing {\n if (!this.image) return nothing;\n\n const imageClasses = { 'main-image': true, loaded: this.loaded };\n const linkClasses = { 'image-link': true, failed: this.failed };\n\n return html`\n <a\n class=${classMap(linkClasses)}\n href=${this.image.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n @click=${this.onClick}\n >\n <img\n class=${classMap(imageClasses)}\n src=${this.image.url}\n alt=${this.image.title ?? this.image.name}\n data-image-name=${this.image.name}\n draggable=\"false\"\n @load=${this.markLoaded}\n @error=${this.markFailed}\n />\n <div class=\"loading-spinner\"></div>\n ${this.failed\n ? html`<p class=\"image-failed\">\n ${msg('This image could not be loaded.')}\n </p>`\n : nothing}\n </a>\n `;\n }\n\n /**\n * Lets the viewer veto opening the image, which it does when the click is\n * the tail end of a swipe. A host can veto it too, to show the image its own\n * way instead of in a new tab.\n */\n private onClick(e: MouseEvent): void {\n if (!this.image) return;\n const allowed = this.dispatchEvent(\n new CustomEvent('imageActivated', {\n detail: { image: this.image },\n bubbles: true,\n cancelable: true,\n }),\n );\n if (!allowed) e.preventDefault();\n }\n\n private markLoaded = (): void => {\n this.loaded = true;\n this.failed = false;\n this.report('imageLoaded');\n };\n\n private markFailed = (): void => {\n this.loaded = false;\n this.failed = true;\n this.report('imageFailed');\n };\n\n /**\n * Tells the viewer what happened to this image, so it can pass failures on\n * to the host. Bubbles because the viewer listens on the track, which is\n * also where the slides it creates by hand during a drag end up.\n */\n private report(name: 'imageLoaded' | 'imageFailed'): void {\n if (!this.image) return;\n this.dispatchEvent(\n new CustomEvent(name, { detail: { image: this.image }, bubbles: true }),\n );\n }\n\n /**\n * Catches an image that finished before its listeners could fire, because\n * the browser had already resolved the request (from the cache or a\n * preload) by the time the element rendered.\n *\n * `complete` is true for a failed image as well as a loaded one, so the two\n * are told apart by `naturalWidth`, which stays 0 when the load failed.\n */\n private checkAlreadyResolved(): void {\n const img = this.imageElement;\n if (!img || this.loaded || this.failed || !img.complete) return;\n if (img.naturalWidth > 0) this.markLoaded();\n else this.markFailed();\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --imgview-slide-spinner-color--: var(\n --image-viewer-spinner-color,\n rgba(255, 255, 255, 0.5)\n );\n --imgview-slide-spinner-track-color--: var(\n --image-viewer-spinner-track-color,\n rgba(255, 255, 255, 0.15)\n );\n --imgview-slide-text-color--: var(\n --image-viewer-text-color,\n var(--true-white)\n );\n --imgview-slide-fade-duration--: var(\n --image-viewer-fade-duration,\n 0.2s\n );\n\n flex: 0 0 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n }\n\n .image-link {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n cursor: pointer;\n }\n\n .main-image {\n display: block;\n max-height: 100%;\n max-width: 100%;\n object-fit: contain;\n opacity: 0;\n transition: opacity var(--imgview-slide-fade-duration--) ease;\n user-select: none;\n }\n\n .main-image.loaded {\n opacity: 1;\n }\n\n .main-image.loaded + .loading-spinner,\n .image-link.failed .loading-spinner {\n display: none;\n }\n\n .loading-spinner {\n position: absolute;\n width: 24px;\n height: 24px;\n border: 2px solid var(--imgview-slide-spinner-track-color--);\n border-top-color: var(--imgview-slide-spinner-color--);\n border-radius: 50%;\n animation: spin 0.8s linear infinite;\n }\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n .image-failed {\n position: absolute;\n margin: 0;\n padding: 0 1.6rem;\n color: var(--imgview-slide-text-color--);\n font-size: 1.4rem;\n text-align: center;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .loading-spinner {\n animation: none;\n }\n\n .main-image {\n transition: none;\n }\n }\n `,\n ];\n }\n}\n
|
|
1
|
+
{"version":3,"file":"ia-imgview-slide.js","sourceRoot":"","sources":["../../../../src/elements/ia-image-viewer/ia-imgview-slide.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EAEH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAGnD;;;;;;;GAOG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QAKY,WAAM,GAAG,KAAK,CAAC;QAEf,WAAM,GAAG,KAAK,CAAC;QA+DxB,eAAU,GAAG,GAAS,EAAE;YAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC7B,CAAC,CAAC;QAEM,eAAU,GAAG,GAAS,EAAE;YAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,MAAM,G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,EAAE;kDAAwB;AAPrB,kBAAkB;IAD9B,aAAa,CAAC,kBAAkB,CAAC;GACrB,kBAAkB,CA2M9B","sourcesContent":["import {\n css,\n type CSSResultGroup,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { ImageViewerImage } from './models';\n\n/**\n * A single image in the viewer's track.\n *\n * Owns everything about one image: its load state, its failure message, and\n * the link that opens the full-size file. The viewer creates these both from\n * its template and by hand during a drag, so the element works with no\n * per-instance setup beyond its properties.\n */\n@customElement('ia-imgview-slide')\nexport class IAImageViewerSlide extends LitElement {\n @property({ type: Object }) image?: ImageViewerImage;\n\n @query('.main-image') private imageElement?: HTMLImageElement;\n\n @state() private loaded = false;\n\n @state() private failed = false;\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('image')) {\n this.loaded = false;\n this.failed = false;\n }\n }\n\n protected updated(): void {\n this.checkAlreadyResolved();\n }\n\n render(): TemplateResult | typeof nothing {\n if (!this.image) return nothing;\n\n const imageClasses = { 'main-image': true, loaded: this.loaded };\n const linkClasses = { 'image-link': true, failed: this.failed };\n\n return html`\n <a\n class=${classMap(linkClasses)}\n href=${this.image.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n @click=${this.onClick}\n >\n <img\n class=${classMap(imageClasses)}\n src=${this.image.url}\n alt=${this.image.title ?? this.image.name}\n data-image-name=${this.image.name}\n draggable=\"false\"\n @load=${this.markLoaded}\n @error=${this.markFailed}\n />\n <div class=\"loading-spinner\"></div>\n ${this.failed\n ? html`<p class=\"image-failed\">\n ${msg('This image could not be loaded.')}\n </p>`\n : nothing}\n </a>\n `;\n }\n\n /**\n * Lets the viewer veto opening the image, which it does when the click is\n * the tail end of a swipe. A host can veto it too, to show the image its own\n * way instead of in a new tab.\n */\n private onClick(e: MouseEvent): void {\n if (!this.image) return;\n const allowed = this.dispatchEvent(\n new CustomEvent('imageActivated', {\n detail: { image: this.image },\n bubbles: true,\n cancelable: true,\n }),\n );\n if (!allowed) e.preventDefault();\n }\n\n private markLoaded = (): void => {\n this.loaded = true;\n this.failed = false;\n this.report('imageLoaded');\n };\n\n private markFailed = (): void => {\n this.loaded = false;\n this.failed = true;\n this.report('imageFailed');\n };\n\n /**\n * Tells the viewer what happened to this image, so it can pass failures on\n * to the host. Bubbles because the viewer listens on the track, which is\n * also where the slides it creates by hand during a drag end up.\n */\n private report(name: 'imageLoaded' | 'imageFailed'): void {\n if (!this.image) return;\n this.dispatchEvent(\n new CustomEvent(name, { detail: { image: this.image }, bubbles: true }),\n );\n }\n\n /**\n * Catches an image that finished before its listeners could fire, because\n * the browser had already resolved the request (from the cache or a\n * preload) by the time the element rendered.\n *\n * `complete` is true for a failed image as well as a loaded one, so the two\n * are told apart by `naturalWidth`, which stays 0 when the load failed.\n */\n private checkAlreadyResolved(): void {\n const img = this.imageElement;\n if (!img || this.loaded || this.failed || !img.complete) return;\n if (img.naturalWidth > 0) this.markLoaded();\n else this.markFailed();\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --imgview-slide-spinner-color--: var(\n --image-viewer-spinner-color,\n rgba(255, 255, 255, 0.5)\n );\n --imgview-slide-spinner-track-color--: var(\n --image-viewer-spinner-track-color,\n rgba(255, 255, 255, 0.15)\n );\n --imgview-slide-text-color--: var(\n --image-viewer-text-color,\n var(--true-white)\n );\n --imgview-slide-fade-duration--: var(\n --image-viewer-fade-duration,\n 0.2s\n );\n\n flex: 0 0 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n }\n\n .image-link {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n cursor: pointer;\n }\n\n .main-image {\n display: block;\n max-height: 100%;\n max-width: 100%;\n object-fit: contain;\n opacity: 0;\n transition: opacity var(--imgview-slide-fade-duration--) ease;\n user-select: none;\n }\n\n .main-image.loaded {\n opacity: 1;\n }\n\n .main-image.loaded + .loading-spinner,\n .image-link.failed .loading-spinner {\n display: none;\n }\n\n .loading-spinner {\n position: absolute;\n width: 24px;\n height: 24px;\n border: 2px solid var(--imgview-slide-spinner-track-color--);\n border-top-color: var(--imgview-slide-spinner-color--);\n border-radius: 50%;\n animation: spin 0.8s linear infinite;\n }\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n .image-failed {\n position: absolute;\n margin: 0;\n padding: 0 1.6rem;\n color: var(--imgview-slide-text-color--);\n font-size: 1.4rem;\n text-align: center;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .loading-spinner {\n animation: none;\n }\n\n .main-image {\n transition: none;\n }\n }\n `,\n ];\n }\n}\n"]}
|
package/package.json
CHANGED