@acorex/components 20.3.45 → 20.3.46
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.
|
@@ -7,7 +7,7 @@ import { isBrowser, AXPlatform } from '@acorex/core/platform';
|
|
|
7
7
|
import { AXTranslatorPipe } from '@acorex/core/translation';
|
|
8
8
|
import { AsyncPipe, CommonModule } from '@angular/common';
|
|
9
9
|
import * as i0 from '@angular/core';
|
|
10
|
-
import { Injectable, signal, inject, input, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, ElementRef, viewChild, contentChild,
|
|
10
|
+
import { Injectable, signal, inject, input, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, ElementRef, afterNextRender, viewChild, contentChild, computed, NgModule } from '@angular/core';
|
|
11
11
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
12
12
|
import { ComponentPortal, CdkPortalOutlet } from '@angular/cdk/portal';
|
|
13
13
|
import { AXImageComponent, AXImageModule } from '@acorex/components/image';
|
|
@@ -96,10 +96,15 @@ class AXThumbnailViewerComponent extends AXMediaViewerBaseComponent {
|
|
|
96
96
|
this.item = input(null, ...(ngDevMode ? [{ debugName: "item" }] : []));
|
|
97
97
|
this.index = input(null, ...(ngDevMode ? [{ debugName: "index" }] : []));
|
|
98
98
|
this.service = inject(AXMediaViewerService);
|
|
99
|
+
this.host = inject(ElementRef);
|
|
99
100
|
this.loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
100
|
-
this
|
|
101
|
+
this.isElementVisible = signal(false, ...(ngDevMode ? [{ debugName: "isElementVisible" }] : []));
|
|
102
|
+
this.#init = afterNextRender(() => {
|
|
103
|
+
this.observeElementVisibility();
|
|
104
|
+
});
|
|
105
|
+
this.#effect = effect(async () => {
|
|
101
106
|
const item = this.item();
|
|
102
|
-
if (this.
|
|
107
|
+
if (this.isElementVisible()) {
|
|
103
108
|
if (this.service.dirtyItems.has(`thumbnail-${this.index()}`)) {
|
|
104
109
|
this.src.set(this.service.dirtyItems.get(`thumbnail-${this.index()}`));
|
|
105
110
|
return;
|
|
@@ -116,12 +121,43 @@ class AXThumbnailViewerComponent extends AXMediaViewerBaseComponent {
|
|
|
116
121
|
}
|
|
117
122
|
this.loading.set(false);
|
|
118
123
|
}
|
|
119
|
-
}, ...(ngDevMode ? [{ debugName: "#
|
|
124
|
+
}, ...(ngDevMode ? [{ debugName: "#effect" }] : []));
|
|
120
125
|
}
|
|
121
126
|
#init;
|
|
127
|
+
#effect;
|
|
122
128
|
handleImageError() {
|
|
123
129
|
this.hasError.set(true);
|
|
124
130
|
}
|
|
131
|
+
observeElementVisibility() {
|
|
132
|
+
const containerEl = this.host.nativeElement.closest('ax-media-viewer-container');
|
|
133
|
+
if (!containerEl)
|
|
134
|
+
return;
|
|
135
|
+
const options = {
|
|
136
|
+
root: containerEl,
|
|
137
|
+
rootMargin: '0px',
|
|
138
|
+
threshold: [0, 1],
|
|
139
|
+
};
|
|
140
|
+
const callback = (entries) => {
|
|
141
|
+
entries.forEach((entry) => {
|
|
142
|
+
if (entry.isIntersecting) {
|
|
143
|
+
this.isElementVisible.set(true);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.isElementVisible.set(false);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
this.observer = new IntersectionObserver(callback, options);
|
|
151
|
+
this.observer.observe(this.host.nativeElement);
|
|
152
|
+
}
|
|
153
|
+
cleanupObserver() {
|
|
154
|
+
if (this.observer) {
|
|
155
|
+
this.observer.disconnect();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
ngOnDestroy() {
|
|
159
|
+
this.cleanupObserver();
|
|
160
|
+
}
|
|
125
161
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXThumbnailViewerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
126
162
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXThumbnailViewerComponent, isStandalone: true, selector: "ax-thumbnail-viewer", inputs: { item: { classPropertyName: "item", publicName: "item", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: AXComponent, useExisting: AXThumbnailViewerComponent }], usesInheritance: true, ngImport: i0, template: "@if (loading()) {\n <ax-loading></ax-loading>\n} @else {\n <ax-image alt=\"image\" [src]=\"src()\" (onError)=\"handleImageError()\">\n @if (hasError()) {\n <ax-placeholder>\n <div class=\"placeholder-image-container\">\n <span class=\"placeholder-image\">\uD83D\uDDBC\uFE0F</span>\n </div>\n </ax-placeholder>\n }\n </ax-image>\n}\n", styles: ["ax-thumbnail-viewer ax-image{width:100%!important;height:100%!important}ax-thumbnail-viewer ax-loading{width:100%;height:100%;display:flex;justify-content:center;align-items:center}ax-thumbnail-viewer .placeholder-image-container{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2rem;text-align:center}ax-thumbnail-viewer .placeholder-image-container .placeholder-image{font-size:3rem;margin-bottom:.5rem}\n"], dependencies: [{ kind: "component", type: AXImageComponent, selector: "ax-image", inputs: ["width", "height", "overlayMode", "src", "alt", "priority", "lazy"], outputs: ["onLoad", "onError"] }, { kind: "component", type: AXLoadingComponent, selector: "ax-loading", inputs: ["visible", "type", "context"], outputs: ["visibleChange"] }, { kind: "component", type: AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
127
163
|
}
|