@ibragim-dev-org/ui-forge-library 1.4.2 → 1.4.22
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.
|
@@ -2,7 +2,7 @@ import * as i2$1 from '@angular/router';
|
|
|
2
2
|
import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
|
|
3
3
|
import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { model, effect, Directive,
|
|
5
|
+
import { model, effect, Directive, output, Input, input, PLATFORM_ID, Inject, EventEmitter, Output, Pipe, Injectable, Attribute, ChangeDetectionStrategy, Component, signal, computed, viewChild, untracked, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
|
|
8
8
|
import * as i2 from '@angular/platform-browser';
|
|
@@ -397,81 +397,61 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
397
397
|
}]
|
|
398
398
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.DestroyRef }], propDecorators: { $focus: [{ type: i0.Input, args: [{ isSignal: true, alias: "appFocus", required: false }] }, { type: i0.Output, args: ["appFocusChange"] }] } });
|
|
399
399
|
|
|
400
|
-
class LazyImageService {
|
|
401
|
-
observer;
|
|
402
|
-
getObserver() {
|
|
403
|
-
if (!this.observer) {
|
|
404
|
-
this.observer = new IntersectionObserver((entries) => {
|
|
405
|
-
entries.forEach((entry) => {
|
|
406
|
-
const img = entry.target;
|
|
407
|
-
if (entry.isIntersecting) {
|
|
408
|
-
const src = img.getAttribute('data-src');
|
|
409
|
-
if (src)
|
|
410
|
-
img.src = src;
|
|
411
|
-
this.observer?.unobserve(img);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
return this.observer;
|
|
417
|
-
}
|
|
418
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
419
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, providedIn: 'root' });
|
|
420
|
-
}
|
|
421
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, decorators: [{
|
|
422
|
-
type: Injectable,
|
|
423
|
-
args: [{ providedIn: 'root' }]
|
|
424
|
-
}] });
|
|
425
|
-
|
|
426
400
|
class LazyImgDirective {
|
|
427
401
|
el;
|
|
428
|
-
lazyService;
|
|
429
402
|
lazySrc;
|
|
430
403
|
loadError = output();
|
|
431
404
|
loaded = output();
|
|
405
|
+
outOfView = output(); // emits when scrolled out
|
|
406
|
+
destroyed = output(); // emits when Angular destroys
|
|
432
407
|
observer;
|
|
433
|
-
|
|
434
|
-
this.loadError.emit();
|
|
435
|
-
};
|
|
436
|
-
onLoad = () => {
|
|
437
|
-
this.loaded.emit();
|
|
438
|
-
};
|
|
439
|
-
constructor(el, lazyService) {
|
|
408
|
+
constructor(el) {
|
|
440
409
|
this.el = el;
|
|
441
|
-
this.lazyService = lazyService;
|
|
442
410
|
}
|
|
443
411
|
ngOnInit() {
|
|
444
412
|
const img = this.el.nativeElement;
|
|
445
413
|
const lazySrc = this.lazySrc?.trim() ?? '';
|
|
446
|
-
if (lazySrc
|
|
414
|
+
if (!lazySrc || /(?:^|\/)null(?:[?#].*)?$/i.test(lazySrc)) {
|
|
447
415
|
this.loadError.emit();
|
|
448
416
|
return;
|
|
449
417
|
}
|
|
450
|
-
img.addEventListener('error', this.
|
|
451
|
-
img.addEventListener('load', this.
|
|
418
|
+
img.addEventListener('error', () => this.loadError.emit());
|
|
419
|
+
img.addEventListener('load', () => this.loaded.emit());
|
|
452
420
|
img.setAttribute('data-src', lazySrc);
|
|
453
|
-
this.observer =
|
|
421
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
422
|
+
entries.forEach((entry) => {
|
|
423
|
+
if (entry.isIntersecting) {
|
|
424
|
+
const src = img.getAttribute('data-src');
|
|
425
|
+
if (src && img.src !== src) {
|
|
426
|
+
img.src = src;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
this.outOfView.emit();
|
|
431
|
+
// optional: unload to force reload later
|
|
432
|
+
// img.removeAttribute('src');
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}, { threshold: 0.1 });
|
|
454
436
|
this.observer.observe(img);
|
|
455
437
|
}
|
|
456
438
|
ngOnDestroy() {
|
|
457
439
|
const img = this.el.nativeElement;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
img.removeEventListener('error', this.onError);
|
|
462
|
-
img.removeEventListener('load', this.onLoad);
|
|
440
|
+
this.observer?.unobserve(img);
|
|
441
|
+
this.observer?.disconnect();
|
|
442
|
+
this.destroyed.emit();
|
|
463
443
|
}
|
|
464
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, deps: [{ token: i0.ElementRef }
|
|
465
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: LazyImgDirective, isStandalone: true, selector: "img[lazySrc]", inputs: { lazySrc: "lazySrc" }, outputs: { loadError: "loadError", loaded: "loaded" }, ngImport: i0 });
|
|
444
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
445
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: LazyImgDirective, isStandalone: true, selector: "img[lazySrc]", inputs: { lazySrc: "lazySrc" }, outputs: { loadError: "loadError", loaded: "loaded", outOfView: "outOfView", destroyed: "destroyed" }, ngImport: i0 });
|
|
466
446
|
}
|
|
467
447
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, decorators: [{
|
|
468
448
|
type: Directive,
|
|
469
449
|
args: [{
|
|
470
450
|
selector: 'img[lazySrc]',
|
|
471
451
|
}]
|
|
472
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }
|
|
452
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { lazySrc: [{
|
|
473
453
|
type: Input
|
|
474
|
-
}], loadError: [{ type: i0.Output, args: ["loadError"] }], loaded: [{ type: i0.Output, args: ["loaded"] }] } });
|
|
454
|
+
}], loadError: [{ type: i0.Output, args: ["loadError"] }], loaded: [{ type: i0.Output, args: ["loaded"] }], outOfView: [{ type: i0.Output, args: ["outOfView"] }], destroyed: [{ type: i0.Output, args: ["destroyed"] }] } });
|
|
475
455
|
|
|
476
456
|
class MaskGradientDirective {
|
|
477
457
|
elementRef;
|