@egjs/ngx-infinitegrid 4.7.1 → 4.8.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/README.md CHANGED
@@ -33,7 +33,9 @@
33
33
 
34
34
  ## ⚙️ Installation
35
35
  ```sh
36
- npm install --save @egjs/ngx-infinitegrid
36
+ npm install @egjs/ngx-infinitegrid
37
+ # Or if you're using yarn
38
+ yarn add @egjs/ngx-infinitegrid
37
39
  ```
38
40
 
39
41
  ## 🏃 Quick Start
@@ -54,22 +56,25 @@ import { NgModule } from '@angular/core';
54
56
  providers: [],
55
57
  bootstrap: [AppComponent]
56
58
  })
57
- export class AppModule { } /* Your app */
59
+ export class AppModule {} /* Your app */
58
60
  ```
59
61
 
60
62
  ```html
61
- <div NgxMasonryInfiniteGrid
63
+ <div
64
+ NgxMasonryInfiniteGrid
62
65
  class="container"
63
66
  [gap]="5"
64
67
  [items]="items"
65
68
  [trackBy]="trackBy"
66
69
  [groupBy]="groupBy"
67
70
  (requestAppend)="onRequestAppend($event)"
68
- *ngFor="let item of [0]; trackBy: randomTrackBy;"
71
+ *ngFor="let item of [0]; trackBy: randomTrackBy"
69
72
  #ig
70
- >
71
- <div class="item" *ngFor ="let item of ig.visibleItems; trackBy: trackBy;">
72
- </div>
73
+ >
74
+ <div
75
+ class="item"
76
+ *ngFor="let item of ig.visibleItems; trackBy: trackBy;"
77
+ ></div>
73
78
  </div>
74
79
  ```
75
80
 
@@ -79,10 +84,11 @@ import { OnRequestAppend } from '@egjs/infinitegrid';
79
84
 
80
85
  @Component({
81
86
  selector: 'app-root',
82
- templateUrl: './app.component.html',
87
+ templateUrl: './app.component.html'
83
88
  })
84
89
  export class AppComponent {
85
90
  items = this.getItems(0, 10);
91
+
86
92
  getItems(nextGroupKey: number, count: number) {
87
93
  const nextItems = [];
88
94
  const nextKey = nextGroupKey * count;
@@ -92,19 +98,19 @@ export class AppComponent {
92
98
  }
93
99
  return nextItems;
94
100
  }
101
+
95
102
  groupBy(_: any, item: any) {
96
103
  return item.groupKey;
97
104
  }
105
+
98
106
  trackBy(_: any, item: any) {
99
107
  return item.key;
100
108
  }
109
+
101
110
  onRequestAppend(e: OnRequestAppend) {
102
111
  const nextGroupKey = (+e.groupKey! || 0) + 1;
103
112
 
104
- this.items = [
105
- ...this.items,
106
- ...this.getItems(nextGroupKey, 10),
107
- ];
113
+ this.items = [...this.items, ...this.getItems(nextGroupKey, 10)];
108
114
  }
109
115
  }
110
116
  ```
@@ -1,41 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@egjs/infinitegrid')) :
3
- typeof define === 'function' && define.amd ? define('@egjs/ngx-infinitegrid', ['exports', '@angular/core', '@angular/common', '@egjs/infinitegrid'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.egjs = global.egjs || {}, global.egjs["ngx-infinitegrid"] = {}), global.ng.core, global.ng.common, global.infinitegrid));
5
- })(this, (function (exports, i0, common, infinitegrid) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
-
27
- var NgxInfinitegridService = /** @class */ (function () {
28
- function NgxInfinitegridService() {
29
- }
30
- return NgxInfinitegridService;
31
- }());
32
- NgxInfinitegridService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function NgxInfinitegridService_Factory() { return new NgxInfinitegridService(); }, token: NgxInfinitegridService, providedIn: "root" });
33
- NgxInfinitegridService.decorators = [
34
- { type: i0.Injectable, args: [{
35
- providedIn: 'root'
36
- },] }
37
- ];
38
- NgxInfinitegridService.ctorParameters = function () { return []; };
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('rxjs'), require('rxjs/operators'), require('@egjs/infinitegrid')) :
3
+ typeof define === 'function' && define.amd ? define('@egjs/ngx-infinitegrid', ['exports', '@angular/core', '@angular/common', 'rxjs', 'rxjs/operators', '@egjs/infinitegrid'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.egjs = global.egjs || {}, global.egjs["ngx-infinitegrid"] = {}), global.ng.core, global.ng.common, global.rxjs, global.rxjs.operators, global.infinitegrid));
5
+ })(this, (function (exports, core, common, rxjs, operators, infinitegrid) { 'use strict';
39
6
 
40
7
  /******************************************************************************
41
8
  Copyright (c) Microsoft Corporation.
@@ -135,7 +102,7 @@
135
102
  function step(op) {
136
103
  if (f)
137
104
  throw new TypeError("Generator is already executing.");
138
- while (_)
105
+ while (g && (g = 0, op[0] && (_ = 0)), _)
139
106
  try {
140
107
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
141
108
  return t;
@@ -373,22 +340,23 @@
373
340
  infinitegrid.withInfiniteGridMethods
374
341
  ], NgxInfiniteGridInterface.prototype, "vanillaGrid", void 0);
375
342
 
376
- // @dynamic
377
343
  var NgxInfiniteGridComponent = /** @class */ (function (_super) {
378
344
  __extends(NgxInfiniteGridComponent, _super);
379
- function NgxInfiniteGridComponent(elementRef, _platform) {
345
+ function NgxInfiniteGridComponent(elementRef, _platformId, _ngZone) {
380
346
  var _this = _super.call(this) || this;
381
347
  _this.elementRef = elementRef;
382
- _this._platform = _platform;
348
+ _this._platformId = _platformId;
349
+ _this._ngZone = _ngZone;
383
350
  _this.items = [];
384
351
  _this.trackBy = (function (_, item) { return item.key; });
385
352
  _this.groupBy = (function (_, item) { return item.groupKey; });
386
353
  _this.visibleItems = [];
387
354
  _this._renderer = new infinitegrid.Renderer();
388
355
  _this._isChange = false;
356
+ _this._destroy$ = new rxjs.Subject();
389
357
  for (var name in infinitegrid.INFINITEGRID_EVENTS) {
390
358
  var eventName = infinitegrid.INFINITEGRID_EVENTS[name];
391
- _this[eventName] = new i0.EventEmitter();
359
+ _this[eventName] = new core.EventEmitter();
392
360
  }
393
361
  return _this;
394
362
  }
@@ -401,36 +369,41 @@
401
369
  };
402
370
  NgxInfiniteGridComponent.prototype.ngAfterViewInit = function () {
403
371
  var _this = this;
404
- var _a;
405
- if (!common.isPlatformBrowser(this._platform)) {
372
+ if (common.isPlatformServer(this._platformId)) {
406
373
  return;
407
374
  }
408
375
  var GridClass = this.constructor.GridClass;
409
376
  var defaultOptions = GridClass.defaultOptions;
410
377
  var options = {};
411
- var containerElement = (_a = this._containerRef) === null || _a === void 0 ? void 0 : _a.nativeElement;
412
378
  for (var name in defaultOptions) {
413
379
  if (name in this && typeof this[name] !== "undefined") {
414
380
  options[name] = this[name];
415
381
  }
416
382
  }
417
- if (containerElement) {
418
- options.container = containerElement;
419
- }
420
383
  options.renderer = this._renderer;
421
- var wrapper = this._wrapperRef || this.elementRef;
422
- var grid = new GridClass(wrapper.nativeElement, options);
384
+ // The `InfiniteGrid` set ups `scroll` and `resize` events through `ScrollManager`
385
+ // and `ResizeWatcher`. These events force Angular to run change detection whenever
386
+ // dispatched; this happens too often.
387
+ var grid = this._ngZone.runOutsideAngular(function () { return new GridClass(_this.elementRef.nativeElement, options); });
423
388
  var _loop_1 = function (name) {
424
389
  var eventName = infinitegrid.INFINITEGRID_EVENTS[name];
425
- grid.on(eventName, function (e) {
426
- _this[eventName].emit(e);
390
+ rxjs.fromEvent(grid, eventName)
391
+ .pipe(operators.takeUntil(this_1._destroy$))
392
+ .subscribe(function (event) {
393
+ var emitter = _this[eventName];
394
+ if (emitter && emitter.observers.length > 0) {
395
+ _this._ngZone.run(function () { return emitter.emit(event); });
396
+ }
427
397
  });
428
398
  };
399
+ var this_1 = this;
429
400
  for (var name in infinitegrid.INFINITEGRID_EVENTS) {
430
401
  _loop_1(name);
431
402
  }
432
403
  this.vanillaGrid = grid;
433
- this._renderer.on("requestUpdate", function () {
404
+ rxjs.fromEvent(this._renderer, 'requestUpdate')
405
+ .pipe(operators.takeUntil(this._destroy$))
406
+ .subscribe(function () {
434
407
  _this._isChange = true;
435
408
  _this._updateVisibleChildren();
436
409
  });
@@ -465,6 +438,7 @@
465
438
  };
466
439
  NgxInfiniteGridComponent.prototype.ngOnDestroy = function () {
467
440
  var _a;
441
+ this._destroy$.next();
468
442
  (_a = this.vanillaGrid) === null || _a === void 0 ? void 0 : _a.destroy();
469
443
  };
470
444
  NgxInfiniteGridComponent.prototype._getItemInfos = function () {
@@ -491,60 +465,60 @@
491
465
  };
492
466
  return NgxInfiniteGridComponent;
493
467
  }(NgxInfiniteGridInterface));
468
+ NgxInfiniteGridComponent.GridClass = null;
494
469
  NgxInfiniteGridComponent.decorators = [
495
- { type: i0.Component, args: [{
470
+ { type: core.Component, args: [{
496
471
  selector: 'ngx-infinite-grid, [NgxInfiniteGrid]',
497
472
  template: '<slot></slot>',
498
473
  styles: [':host { display: block }']
499
474
  },] }
500
475
  ];
501
476
  NgxInfiniteGridComponent.ctorParameters = function () { return [
502
- { type: i0.ElementRef },
503
- { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
477
+ { type: core.ElementRef },
478
+ { type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
479
+ { type: core.NgZone }
504
480
  ]; };
505
481
  NgxInfiniteGridComponent.propDecorators = {
506
- gridConstructor: [{ type: i0.Input }],
507
- renderer: [{ type: i0.Input }],
508
- container: [{ type: i0.Input }],
509
- containerTag: [{ type: i0.Input }],
510
- threshold: [{ type: i0.Input }],
511
- useRecycle: [{ type: i0.Input }],
512
- horizontal: [{ type: i0.Input }],
513
- percentage: [{ type: i0.Input }],
514
- isEqualSize: [{ type: i0.Input }],
515
- isConstantSize: [{ type: i0.Input }],
516
- gap: [{ type: i0.Input }],
517
- attributePrefix: [{ type: i0.Input }],
518
- resizeDebounce: [{ type: i0.Input }],
519
- maxResizeDebounce: [{ type: i0.Input }],
520
- autoResize: [{ type: i0.Input }],
521
- useFit: [{ type: i0.Input }],
522
- useTransform: [{ type: i0.Input }],
523
- renderOnPropertyChange: [{ type: i0.Input }],
524
- preserveUIOnDestroy: [{ type: i0.Input }],
525
- defaultDirection: [{ type: i0.Input }],
526
- externalItemRenderer: [{ type: i0.Input }],
527
- externalContainerManager: [{ type: i0.Input }],
528
- outlineLength: [{ type: i0.Input }],
529
- outlineSize: [{ type: i0.Input }],
530
- useRoundedSize: [{ type: i0.Input }],
531
- useResizeObserver: [{ type: i0.Input }],
532
- observeChildren: [{ type: i0.Input }],
533
- scrollContainer: [{ type: i0.Input }],
534
- usePlaceholder: [{ type: i0.Input }],
535
- useLoading: [{ type: i0.Input }],
536
- status: [{ type: i0.Input }],
537
- useFirstRender: [{ type: i0.Input }],
538
- items: [{ type: i0.Input }],
539
- trackBy: [{ type: i0.Input }],
540
- groupBy: [{ type: i0.Input }],
541
- renderComplete: [{ type: i0.Output }],
542
- contentError: [{ type: i0.Output }],
543
- changeScroll: [{ type: i0.Output }],
544
- requestAppend: [{ type: i0.Output }],
545
- requestPrepend: [{ type: i0.Output }],
546
- _wrapperRef: [{ type: i0.ViewChild, args: ['wrapperRef', { static: false },] }],
547
- _containerRef: [{ type: i0.ViewChild, args: ['containerRef', { static: false },] }]
482
+ gridConstructor: [{ type: core.Input }],
483
+ renderer: [{ type: core.Input }],
484
+ container: [{ type: core.Input }],
485
+ containerTag: [{ type: core.Input }],
486
+ threshold: [{ type: core.Input }],
487
+ useRecycle: [{ type: core.Input }],
488
+ horizontal: [{ type: core.Input }],
489
+ percentage: [{ type: core.Input }],
490
+ isEqualSize: [{ type: core.Input }],
491
+ isConstantSize: [{ type: core.Input }],
492
+ gap: [{ type: core.Input }],
493
+ attributePrefix: [{ type: core.Input }],
494
+ resizeDebounce: [{ type: core.Input }],
495
+ maxResizeDebounce: [{ type: core.Input }],
496
+ autoResize: [{ type: core.Input }],
497
+ useFit: [{ type: core.Input }],
498
+ useTransform: [{ type: core.Input }],
499
+ renderOnPropertyChange: [{ type: core.Input }],
500
+ preserveUIOnDestroy: [{ type: core.Input }],
501
+ defaultDirection: [{ type: core.Input }],
502
+ externalItemRenderer: [{ type: core.Input }],
503
+ externalContainerManager: [{ type: core.Input }],
504
+ outlineLength: [{ type: core.Input }],
505
+ outlineSize: [{ type: core.Input }],
506
+ useRoundedSize: [{ type: core.Input }],
507
+ useResizeObserver: [{ type: core.Input }],
508
+ observeChildren: [{ type: core.Input }],
509
+ scrollContainer: [{ type: core.Input }],
510
+ usePlaceholder: [{ type: core.Input }],
511
+ useLoading: [{ type: core.Input }],
512
+ status: [{ type: core.Input }],
513
+ useFirstRender: [{ type: core.Input }],
514
+ items: [{ type: core.Input }],
515
+ trackBy: [{ type: core.Input }],
516
+ groupBy: [{ type: core.Input }],
517
+ renderComplete: [{ type: core.Output }],
518
+ contentError: [{ type: core.Output }],
519
+ changeScroll: [{ type: core.Output }],
520
+ requestAppend: [{ type: core.Output }],
521
+ requestPrepend: [{ type: core.Output }]
548
522
  };
549
523
 
550
524
  var TEMPLATE = "\n<ng-template #content><ng-content></ng-content></ng-template>\n\n<ng-template #viewer>\n <ng-template [ngIf]=\"container === true\" [ngIfElse]=\"noContainer\">\n <div #containerRef>\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n </div>\n </ng-template>\n <ng-template #noContainer>\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n </ng-template>\n</ng-template>\n\n<ng-template [ngIf]=\"elementRef.nativeElement.tagName.indexOf('NGX-') === 0\" [ngIfElse]=\"noWrapper\">\n <div #wrapperRef>\n <ng-container *ngTemplateOutlet=\"viewer\"></ng-container>\n </div>\n</ng-template>\n\n<ng-template #noWrapper>\n <ng-container *ngTemplateOutlet=\"viewer\"></ng-container>\n</ng-template>\n";
@@ -558,18 +532,18 @@
558
532
  }(NgxInfiniteGridComponent));
559
533
  NgxMasonryInfiniteGridComponent.GridClass = infinitegrid.MasonryInfiniteGrid;
560
534
  NgxMasonryInfiniteGridComponent.decorators = [
561
- { type: i0.Component, args: [{
535
+ { type: core.Component, args: [{
562
536
  selector: 'ngx-masonry-infinite-grid, [NgxMasonryInfiniteGrid]',
563
537
  template: TEMPLATE
564
538
  },] }
565
539
  ];
566
540
  NgxMasonryInfiniteGridComponent.propDecorators = {
567
- column: [{ type: i0.Input }],
568
- columnSize: [{ type: i0.Input }],
569
- columnSizeRatio: [{ type: i0.Input }],
570
- align: [{ type: i0.Input }],
571
- columnCalculationThreshold: [{ type: i0.Input }],
572
- maxStretchColumnSize: [{ type: i0.Input }]
541
+ column: [{ type: core.Input }],
542
+ columnSize: [{ type: core.Input }],
543
+ columnSizeRatio: [{ type: core.Input }],
544
+ align: [{ type: core.Input }],
545
+ columnCalculationThreshold: [{ type: core.Input }],
546
+ maxStretchColumnSize: [{ type: core.Input }]
573
547
  };
574
548
 
575
549
  var NgxJustifiedInfiniteGridComponent = /** @class */ (function (_super) {
@@ -581,17 +555,17 @@
581
555
  }(NgxInfiniteGridComponent));
582
556
  NgxJustifiedInfiniteGridComponent.GridClass = infinitegrid.JustifiedInfiniteGrid;
583
557
  NgxJustifiedInfiniteGridComponent.decorators = [
584
- { type: i0.Component, args: [{
558
+ { type: core.Component, args: [{
585
559
  selector: 'ngx-justified-infinite-grid, [NgxJustifiedInfiniteGrid]',
586
560
  template: TEMPLATE
587
561
  },] }
588
562
  ];
589
563
  NgxJustifiedInfiniteGridComponent.propDecorators = {
590
- columnRange: [{ type: i0.Input }],
591
- rowRange: [{ type: i0.Input }],
592
- sizeRange: [{ type: i0.Input }],
593
- displayedRow: [{ type: i0.Input }],
594
- isCroppedSize: [{ type: i0.Input }]
564
+ columnRange: [{ type: core.Input }],
565
+ rowRange: [{ type: core.Input }],
566
+ sizeRange: [{ type: core.Input }],
567
+ displayedRow: [{ type: core.Input }],
568
+ isCroppedSize: [{ type: core.Input }]
595
569
  };
596
570
 
597
571
  var NgxFrameInfiniteGridComponent = /** @class */ (function (_super) {
@@ -603,15 +577,15 @@
603
577
  }(NgxInfiniteGridComponent));
604
578
  NgxFrameInfiniteGridComponent.GridClass = infinitegrid.FrameInfiniteGrid;
605
579
  NgxFrameInfiniteGridComponent.decorators = [
606
- { type: i0.Component, args: [{
580
+ { type: core.Component, args: [{
607
581
  selector: 'ngx-frame-infinite-grid, [NgxFrameInfiniteGrid]',
608
582
  template: TEMPLATE
609
583
  },] }
610
584
  ];
611
585
  NgxFrameInfiniteGridComponent.propDecorators = {
612
- frame: [{ type: i0.Input }],
613
- useFrameFill: [{ type: i0.Input }],
614
- rectSize: [{ type: i0.Input }]
586
+ frame: [{ type: core.Input }],
587
+ useFrameFill: [{ type: core.Input }],
588
+ rectSize: [{ type: core.Input }]
615
589
  };
616
590
 
617
591
  var NgxPackingInfiniteGridComponent = /** @class */ (function (_super) {
@@ -623,16 +597,16 @@
623
597
  }(NgxInfiniteGridComponent));
624
598
  NgxPackingInfiniteGridComponent.GridClass = infinitegrid.PackingInfiniteGrid;
625
599
  NgxPackingInfiniteGridComponent.decorators = [
626
- { type: i0.Component, args: [{
600
+ { type: core.Component, args: [{
627
601
  selector: 'ngx-packing-infinite-grid, [NgxPackingInfiniteGrid]',
628
602
  template: TEMPLATE
629
603
  },] }
630
604
  ];
631
605
  NgxPackingInfiniteGridComponent.propDecorators = {
632
- aspectRatio: [{ type: i0.Input }],
633
- sizeWeight: [{ type: i0.Input }],
634
- ratioWeight: [{ type: i0.Input }],
635
- weightPriority: [{ type: i0.Input }]
606
+ aspectRatio: [{ type: core.Input }],
607
+ sizeWeight: [{ type: core.Input }],
608
+ ratioWeight: [{ type: core.Input }],
609
+ weightPriority: [{ type: core.Input }]
636
610
  };
637
611
 
638
612
  var NgxInfiniteGridModule = /** @class */ (function () {
@@ -641,7 +615,7 @@
641
615
  return NgxInfiniteGridModule;
642
616
  }());
643
617
  NgxInfiniteGridModule.decorators = [
644
- { type: i0.NgModule, args: [{
618
+ { type: core.NgModule, args: [{
645
619
  declarations: [
646
620
  NgxInfiniteGridComponent,
647
621
  NgxMasonryInfiniteGridComponent,
@@ -672,7 +646,6 @@
672
646
 
673
647
  exports.NgxInfiniteGridComponent = NgxInfiniteGridComponent;
674
648
  exports.NgxInfiniteGridModule = NgxInfiniteGridModule;
675
- exports.NgxInfinitegridService = NgxInfinitegridService;
676
649
  exports.NgxMasonryInfiniteGridComponent = NgxMasonryInfiniteGridComponent;
677
650
  exports["ɵa"] = NgxInfiniteGridInterface;
678
651
  exports["ɵb"] = TEMPLATE;