@stemy/ngx-utils 19.4.15 → 19.4.16
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/fesm2022/stemy-ngx-utils.mjs +40 -5
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +1 -1
- package/ngx-utils/ngx-utils.imports.d.ts +2 -2
- package/ngx-utils/plugins/resize-detector.d.ts +11 -0
- package/ngx-utils/plugins/resize-event.plugin.d.ts +2 -2
- package/package.json +1 -1
|
@@ -4399,6 +4399,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
4399
4399
|
args: [DOCUMENT]
|
|
4400
4400
|
}] }, { type: UniversalService }] });
|
|
4401
4401
|
|
|
4402
|
+
class ResizeDetector {
|
|
4403
|
+
constructor(resizeStrategy) {
|
|
4404
|
+
this.resizeStrategy = resizeStrategy;
|
|
4405
|
+
this.detector = elementResizeDetectorMaker({
|
|
4406
|
+
strategy: resizeStrategy === "observer" ? "object" : resizeStrategy
|
|
4407
|
+
});
|
|
4408
|
+
this.isObservable = resizeStrategy === "observer" && typeof ResizeObserver === "function";
|
|
4409
|
+
this.observers = new Map();
|
|
4410
|
+
}
|
|
4411
|
+
listenTo(elem, cb) {
|
|
4412
|
+
if (!this.isObservable) {
|
|
4413
|
+
this.detector.listenTo(elem, cb);
|
|
4414
|
+
return;
|
|
4415
|
+
}
|
|
4416
|
+
if (this.observers.has(elem))
|
|
4417
|
+
return;
|
|
4418
|
+
const observer = new ResizeObserver(() => {
|
|
4419
|
+
requestAnimationFrame(() => {
|
|
4420
|
+
cb(elem);
|
|
4421
|
+
});
|
|
4422
|
+
});
|
|
4423
|
+
observer.observe(elem);
|
|
4424
|
+
this.observers.set(elem, observer);
|
|
4425
|
+
}
|
|
4426
|
+
uninstall(elem) {
|
|
4427
|
+
if (!this.isObservable) {
|
|
4428
|
+
this.detector.uninstall(elem);
|
|
4429
|
+
return;
|
|
4430
|
+
}
|
|
4431
|
+
if (!this.observers.has(elem))
|
|
4432
|
+
return;
|
|
4433
|
+
const observer = this.observers.get(elem);
|
|
4434
|
+
observer.unobserve(elem);
|
|
4435
|
+
this.observers.delete(elem);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4402
4439
|
function emptyRemove$1() {
|
|
4403
4440
|
}
|
|
4404
4441
|
function isWindow(el) {
|
|
@@ -4411,9 +4448,7 @@ class ResizeEventPlugin extends _DomEventsPlugin {
|
|
|
4411
4448
|
this.resizeDelay = resizeDelay;
|
|
4412
4449
|
this.resizeStrategy = resizeStrategy;
|
|
4413
4450
|
this.universal = universal;
|
|
4414
|
-
this.detector =
|
|
4415
|
-
strategy: resizeStrategy
|
|
4416
|
-
});
|
|
4451
|
+
this.detector = new ResizeDetector(resizeStrategy);
|
|
4417
4452
|
}
|
|
4418
4453
|
supports(eventName) {
|
|
4419
4454
|
return eventName === ResizeEventPlugin.EVENT_NAME;
|
|
@@ -4424,7 +4459,7 @@ class ResizeEventPlugin extends _DomEventsPlugin {
|
|
|
4424
4459
|
if (this.universal.isServer)
|
|
4425
4460
|
return emptyRemove$1;
|
|
4426
4461
|
const timer = TimerUtils.createTimeout();
|
|
4427
|
-
const cb = el => {
|
|
4462
|
+
const cb = (el) => {
|
|
4428
4463
|
timer.set(() => {
|
|
4429
4464
|
zone.run(() => handler(el));
|
|
4430
4465
|
}, this.resizeDelay);
|
|
@@ -8057,7 +8092,7 @@ class NgxUtilsModule {
|
|
|
8057
8092
|
},
|
|
8058
8093
|
{
|
|
8059
8094
|
provide: RESIZE_STRATEGY,
|
|
8060
|
-
useValue: (!config ? null : config.resizeStrategy) ?? "
|
|
8095
|
+
useValue: (!config ? null : config.resizeStrategy) ?? "observer",
|
|
8061
8096
|
},
|
|
8062
8097
|
{
|
|
8063
8098
|
provide: SOCKET_IO_PATH,
|