@egjs/ngx-infinitegrid 3.3.0 → 4.1.2-beta.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.
Files changed (57) hide show
  1. package/README.md +111 -178
  2. package/bundles/egjs-ngx-infinitegrid.umd.js +586 -750
  3. package/bundles/egjs-ngx-infinitegrid.umd.js.map +1 -1
  4. package/bundles/egjs-ngx-infinitegrid.umd.min.js +12 -12
  5. package/bundles/egjs-ngx-infinitegrid.umd.min.js.map +1 -1
  6. package/egjs-ngx-infinitegrid.d.ts +5 -1
  7. package/egjs-ngx-infinitegrid.metadata.json +1 -1
  8. package/esm2015/egjs-ngx-infinitegrid.js +7 -7
  9. package/esm2015/lib/consts.js +20 -23
  10. package/esm2015/lib/grids/ngx-frame-infinitegrid.component.js +19 -0
  11. package/esm2015/lib/grids/ngx-justified-infinitegrid.component.js +21 -0
  12. package/esm2015/lib/grids/ngx-masonry-infinitegrid.component.js +20 -0
  13. package/esm2015/lib/grids/ngx-packing-infinitegrid.component.js +20 -0
  14. package/esm2015/lib/ngx-infinitegrid.component.js +134 -311
  15. package/esm2015/lib/ngx-infinitegrid.interface.js +10 -18
  16. package/esm2015/lib/ngx-infinitegrid.module.js +14 -21
  17. package/esm2015/lib/ngx-infinitegrid.service.js +5 -10
  18. package/esm2015/lib/types.js +2 -5
  19. package/esm2015/public-api.js +5 -13
  20. package/fesm2015/egjs-ngx-infinitegrid.js +214 -475
  21. package/fesm2015/egjs-ngx-infinitegrid.js.map +1 -1
  22. package/lib/consts.d.ts +1 -1
  23. package/lib/grids/ngx-frame-infinitegrid.component.d.ts +8 -0
  24. package/lib/grids/ngx-justified-infinitegrid.component.d.ts +10 -0
  25. package/lib/grids/ngx-masonry-infinitegrid.component.d.ts +9 -0
  26. package/lib/grids/ngx-packing-infinitegrid.component.d.ts +9 -0
  27. package/lib/ngx-infinitegrid.component.d.ts +57 -37
  28. package/lib/ngx-infinitegrid.interface.d.ts +9 -5
  29. package/lib/ngx-infinitegrid.service.d.ts +1 -1
  30. package/lib/types.d.ts +18 -4
  31. package/package.json +19 -16
  32. package/public-api.d.ts +1 -5
  33. package/esm2015/lib/ngx-framelayout.component.js +0 -28
  34. package/esm2015/lib/ngx-gridlayout.component.js +0 -28
  35. package/esm2015/lib/ngx-justifiedlayout.component.js +0 -28
  36. package/esm2015/lib/ngx-packinglayout.component.js +0 -28
  37. package/esm2015/lib/ngx-squarelayout.component.js +0 -28
  38. package/esm5/egjs-ngx-infinitegrid.js +0 -10
  39. package/esm5/lib/consts.js +0 -8
  40. package/esm5/lib/ngx-framelayout.component.js +0 -33
  41. package/esm5/lib/ngx-gridlayout.component.js +0 -33
  42. package/esm5/lib/ngx-infinitegrid.component.js +0 -385
  43. package/esm5/lib/ngx-infinitegrid.interface.js +0 -25
  44. package/esm5/lib/ngx-infinitegrid.module.js +0 -42
  45. package/esm5/lib/ngx-infinitegrid.service.js +0 -21
  46. package/esm5/lib/ngx-justifiedlayout.component.js +0 -33
  47. package/esm5/lib/ngx-packinglayout.component.js +0 -33
  48. package/esm5/lib/ngx-squarelayout.component.js +0 -33
  49. package/esm5/lib/types.js +0 -5
  50. package/esm5/public-api.js +0 -16
  51. package/fesm5/egjs-ngx-infinitegrid.js +0 -611
  52. package/fesm5/egjs-ngx-infinitegrid.js.map +0 -1
  53. package/lib/ngx-framelayout.component.d.ts +0 -5
  54. package/lib/ngx-gridlayout.component.d.ts +0 -5
  55. package/lib/ngx-justifiedlayout.component.d.ts +0 -5
  56. package/lib/ngx-packinglayout.component.d.ts +0 -5
  57. package/lib/ngx-squarelayout.component.d.ts +0 -5
package/README.md CHANGED
@@ -1,234 +1,163 @@
1
- # ngx-infinitegrid [![npm version](https://badge.fury.io/js/%40egjs%2Fngx-infinitegrid.svg)](https://badge.fury.io/js/%40egjs%2Fngx-infinitegrid)
2
-
3
- An Angular component that can easily use [egjs-infinitegrid](https://github.com/naver/egjs-infinitegrid)
4
- * [Playground with Various Demos](https://naver.github.io/egjs-infinitegrid/storybook/)
5
- * [GridLayout Demo](https://codesandbox.io/s/ngx-infinitegrid-demo-gridlayout-vu7pp)
6
- * [GridLayout with Parallax Demo](https://codesandbox.io/s/ngx-infinitegrid-parallax-demo-gridlayout-cvxg5)
7
- * [JustifiedLayout Demo](https://codesandbox.io/s/ngx-infinitegrid-demo-justifiedlayout-ypvf7)
8
- * [Youtube Demo](https://codesandbox.io/s/ngx-infinitegrid-youtube-demo-m1npy)
9
- * [API Documentation](https://naver.github.io/egjs-infinitegrid/release/latest/doc/)
10
-
11
-
12
- ## Install
13
- ```bash
14
- $ npm install @egjs/ngx-infinitegrid --save
1
+ <h1 align="center">
2
+ <img width="256" alt="InfiniteGrid Logo" src="https://naver.github.io/egjs-infinitegrid/img/infinitegrid_logo.png"><br/>
3
+ @egjs/ngx-infinitegrid
4
+ </h1>
5
+
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/@egjs/ngx-infinitegrid" target="_blank">
8
+ <img src="https://img.shields.io/npm/v/@egjs/ngx-infinitegrid.svg?style=flat-square&color=dd0031&label=version&logo=NPM">
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/@egjs/ngx-infinitegrid" target="_blank">
11
+ <img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@egjs/ngx-infinitegrid.svg?style=flat-square&label=%F0%9F%92%BE%20gzipped&color=007acc">
12
+ </a>
13
+ <a href="https://github.com/naver/egjs-infinitegrid/graphs/commit-activity">
14
+ <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/naver/egjs-infinitegrid.svg?style=flat-square&label=%E2%AC%86%20commits&color=08CE5D">
15
+ </a>
16
+ <a href="https://www.npmjs.com/package/@egjs/ngx-infinitegrid" target="_blank">
17
+ <img src="https://img.shields.io/npm/dm/@egjs/ngx-infinitegrid.svg?style=flat-square&label=%E2%AC%87%20downloads&color=08CE5D" alt="npm downloads per month">
18
+ </a>
19
+ <a href="https://github.com/naver/egjs-infinitegrid/graphs/contributors" target="_blank">
20
+ <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/naver/egjs-infinitegrid.svg?label=%F0%9F%91%A5%20contributors&style=flat-square&color=08CE5D"></a>
21
+ <a href="https://github.com/naver/egjs-infinitegrid/blob/master/LICENSE" target="_blank">
22
+ <img alt="GitHub" src="https://img.shields.io/github/license/naver/egjs-infinitegrid.svg?style=flat-square&label=%F0%9F%93%9C%20license&color=08CE5D">
23
+ </a>
24
+ </p>
25
+
26
+ <p align="center">
27
+ An Angular component that can arrange items infinitely according to the type of grids
28
+ </p>
29
+
30
+ <p align="center">
31
+ <a href="https://naver.github.io/egjs-infinitegrid/">Demo</a> / <a href="https://naver.github.io/egjs-infinitegrid/docs/api/InfiniteGrid">Documentation</a> / <a href="https://naver.github.io/egjs/">Other components</a>
32
+ </p>
33
+
34
+ ## ⚙️ Installation
35
+ ```sh
36
+ npm install --save @egjs/ngx-infinitegrid
15
37
  ```
16
38
 
17
- ## How to use
18
-
19
- ### Module
20
- ```js
39
+ ## 🏃 Quick Start
40
+ ### Module definition
41
+ ```diff
42
+ +import { NgxInfiniteGridModule } from '@egjs/ngx-infinitegrid';
21
43
  import { BrowserModule } from '@angular/platform-browser';
22
44
  import { NgModule } from '@angular/core';
23
- import { AppComponent } from './app.component';
24
-
25
- import {
26
- NgxInfiniteGridModule,
27
- NgxInfiniteGridComponent,
28
- NgxGridLayoutComponent,
29
- NgxJustifiedLayoutComponent,
30
- NgxSquareLayoutComponent,
31
- NgxFrameLayoutComponent,
32
- NgxPackingLayoutComponent,
33
- } from '@egjs/ngx-infinitegrid';
34
-
45
+
35
46
  @NgModule({
36
47
  declarations: [
37
- AppComponent,
38
- NgxGridLayoutComponent,
48
+ AppComponent
39
49
  ],
40
50
  imports: [
41
51
  BrowserModule,
42
- // NgxInfiniteGridModule,
52
+ + NgxInfiniteGridModule /* Add in imports */
43
53
  ],
44
54
  providers: [],
45
55
  bootstrap: [AppComponent]
46
56
  })
47
- export class AppModule {}
57
+ export class AppModule { } /* Your app */
48
58
  ```
49
59
 
50
- ### App
60
+ ```html
61
+ <div NgxMasonryInfiniteGrid
62
+ class="container"
63
+ [gap]="5"
64
+ [items]="items"
65
+ [trackBy]="trackBy"
66
+ [groupBy]="groupBy"
67
+ (requestAppend)="onRequestAppend($event)"
68
+ *ngFor="let item of [0]; trackBy: randomTrackBy;"
69
+ #ig
70
+ >
71
+ <div class="item" *ngFor ="let item of ig.visibleItems; trackBy: trackBy;">
72
+ </div>
73
+ </div>
74
+ ```
51
75
 
52
76
  ```ts
77
+ import { Component, Input } from '@angular/core';
78
+ import { OnRequestAppend } from '@egjs/infinitegrid';
79
+
53
80
  @Component({
54
81
  selector: 'app-root',
55
82
  templateUrl: './app.component.html',
56
- styleUrls: ['./app.component.css']
57
83
  })
58
84
  export class AppComponent {
59
- options={
60
- threshold: 100,
61
- isOverflowScroll: false,
62
- isEqualSize: false,
63
- isContantSize: false,
64
- useFit: false,
65
- useRecycle: false,
66
- horizontal: false,
67
- };
68
- layoutOptions={
69
- align: "justify",
70
- };
71
- start = 0;
72
- items = [];
73
- loadItems(groupKey: number, num: number) {
74
- const items = this.items;
75
- const start = this.start || 0;
76
-
77
- for (let i = 0; i < num; ++i) {
78
- items.push({
79
- groupKey,
80
- itemKey: start + i,
81
- no: start + i,
82
- });
83
- }
84
- this.items = [...items];
85
- this.start += num;
86
- }
87
- onAppend({ currentTarget, groupKey, startLoading }) {
88
- (window as any).a = this;
89
- if (currentTarget.isLoading()) {
90
- return;
91
- }
92
- startLoading();
93
- this.loadItems(parseFloat(groupKey || 0) + 1, 5);
94
- }
95
- onLayoutComplete({ isAppend, isLayout, endLoading, fromCache }) {
96
- if (!isLayout) {
97
- endLoading();
85
+ items = this.getItems(0, 10);
86
+ getItems(nextGroupKey: number, count: number) {
87
+ const nextItems = [];
88
+ const nextKey = nextGroupKey * count;
89
+
90
+ for (let i = 0; i < count; ++i) {
91
+ nextItems.push({ groupKey: nextGroupKey, key: nextKey + i });
98
92
  }
93
+ return nextItems;
99
94
  }
100
- onImageError({ totalIndex }) {
101
- this.items.splice(totalIndex, 1);
102
- this.items = [ ...this.items ];
103
- }
104
- onChange(e) {
105
- console.log(e);
106
- }
107
- onPrepend(e) {
108
- console.log(e);
95
+ groupBy(_: any, item: any) {
96
+ return item.groupKey;
109
97
  }
110
- trackBy(index: number, item: IItem): any {
111
- return item.itemKey;
98
+ trackBy(_: any, item: any) {
99
+ return item.key;
112
100
  }
113
- groupBy(index: number, item: IItem): any {
114
- return item.groupKey;
101
+ onRequestAppend(e: OnRequestAppend) {
102
+ const nextGroupKey = (+e.groupKey! || 0) + 1;
103
+
104
+ this.items = [
105
+ ...this.items,
106
+ ...this.getItems(nextGroupKey, 10),
107
+ ];
115
108
  }
116
109
  }
117
-
118
- ```
119
-
120
- ### Template
121
- ```html
122
- <ngx-gridlayout #ig
123
- [loading]="loading"
124
- [options]="options"
125
- [layoutOptions]="layoutOptions"
126
- [items]="items"
127
- [trackBy]="trackBy"
128
- [groupBy]="groupBy"
129
- (append)="onAppend($event)"
130
- (prepend)="onPrepend($event)"
131
- (change)="onChange($event)"
132
- (layoutComplete)="onLayoutComplete($event)"
133
- (imageError)="onImageError($event)">
134
- <div class="loading" #loading>LOADING?</div>
135
- <div class="item" *ngFor ="let item of ig.visibleItems; trackBy: trackBy;">
136
- egjs {{item.no}}
137
- </div>
138
- </ngx-gridlayout>
139
110
  ```
140
111
 
141
112
 
142
- ## Props
143
-
144
- |name|type|default|description|
145
- |---|---|---|---|
146
- |trackBy|Function|get itemKey|Get a unique key that defines how to track changes for items in the iterable.|
147
- |groupBy|Function|get groupKey or data-groupkey|Get a unique key to distinguish between groups.|
148
- |useFirstRender|boolean|false|The useFirstRender option determines whether the markup will be shown on the first rendering or after loading is complete.|
149
- |loading|HTMLElement||Specifies the Loading Bar to use for append or prepend items.|
150
- |status|IInfiniteGridStatus|null|State object of the react-infinitegrid module|
151
- |layoutType|Class|GridLayout|Specifies the Layout class to use.|
152
- |options|IInfiniteGridOptions|{}|The option object of the eg.InfiniteGrid module|
153
- |layoutOptions|IInfiniteGridOptions|{}|Options to apply to the Layout.|
154
-
155
-
156
- ### Options
157
- * [InfiniteGrid's options](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.html)
158
- * [InfiniteGrid's events](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.html#event:append)
159
- * [GridLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.GridLayout.html)
160
- * [JustifiedLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.JustifiedLayout.html)
161
- * [SquareLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.SquareLayout.html)
162
- * [FrameLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.FrameLayout.html)
163
- * [PackingLayout's layoutOptions](https://naver.github.io/egjs-infinitegrid/release/latest/doc/eg.InfiniteGrid.PackingLayout.html)
113
+ ## 📖 More Options & Examples
114
+ [Options](https://naver.github.io/egjs-infinitegrid/Options) / [Demos](https://naver.github.io/egjs-infinitegrid/Demos)
164
115
 
116
+ ## 🙌 Contributing
117
+ See [CONTRIBUTING.md](https://github.com/naver/egjs-infinitegrid/blob/master/CONTRIBUTING.md)
165
118
 
119
+ ## 📝 Feedback
120
+ Please file an [Issue](https://github.com/naver/egjs-infinitegrid/issues) with label "Angular".
166
121
 
167
- ### Restore status
168
-
169
- If you want to restore the state, use the status prop.
170
-
171
- * Save Status
172
- ```html
173
- <GridLayout #ig></GridLayout>
122
+ ## Local development
123
+ ### Project setup
174
124
  ```
175
- ```tsx
176
- import { NgxGridLayoutComponent } from "@egjs/ngx-infinitegrid";
177
-
178
- @ViewChild('ig', { static: false }) ig: NgxGridLayoutComponent;
179
-
180
- // Save Status
181
- this.ig.getStatus();
125
+ npm install
182
126
  ```
183
127
 
184
- * Restore Status (First mount)
185
- ```html
186
-
187
- <GridLayout
188
- [status]="status"></GridLayout>
128
+ ### Compiles and hot-reloads demo
129
+ ```sh
130
+ npm run start
189
131
  ```
190
132
 
191
- * Dynamically restore status
192
- ```ts
193
- import { NgxGridLayoutComponent } from "@egjs/ngx-infinitegrid";
194
-
195
- @ViewChild('ig', { static: false }) ig: NgxGridLayoutComponent;
196
-
197
- this.ig.setStatus(status);
133
+ ### Compiles and minifies for production
134
+ ```
135
+ npm run build
198
136
  ```
199
137
 
200
- ## ⚙️ Development
201
-
202
- This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0.1.
203
-
204
- ## Development server
205
-
206
- Run `npm run start(ng serve)` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
207
-
208
-
209
-
210
- ## Bug Report
211
-
212
- If you find a bug, please report it to us using the [Issues](https://github.com/naver/egjs-infinitegrid/issues) page on GitHub.
213
-
138
+ ### Run your tests
139
+ ```
140
+ npm run test
141
+ ```
214
142
 
215
- ## License
216
- react-infinitegrid is released under the [MIT license](https://github.com/naver/egjs-infinitegrid/blob/master/LICENSE).
143
+ ### Lints and fixes files
144
+ ```
145
+ npm run lint
146
+ ```
217
147
 
148
+ ## 📜 License
149
+ egjs-infinitegrid is released under the [MIT license](http://naver.github.io/egjs/license.txt).
218
150
 
219
151
  ```
220
- Copyright (c) 2019-present NAVER Corp.
221
-
152
+ Copyright (c) 2015-present NAVER Corp.
222
153
  Permission is hereby granted, free of charge, to any person obtaining a copy
223
154
  of this software and associated documentation files (the "Software"), to deal
224
155
  in the Software without restriction, including without limitation the rights
225
156
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
226
157
  copies of the Software, and to permit persons to whom the Software is
227
158
  furnished to do so, subject to the following conditions:
228
-
229
159
  The above copyright notice and this permission notice shall be included in
230
160
  all copies or substantial portions of the Software.
231
-
232
161
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
233
162
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
234
163
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -238,3 +167,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
238
167
  THE SOFTWARE.
239
168
  ```
240
169
 
170
+ <p align="center">
171
+ <a href="https://naver.github.io/egjs/"><img height="50" src="https://naver.github.io/egjs/img/logotype1_black.svg" ></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/naver"><img height="50" src="https://naver.github.io/OpenSourceGuide/book/assets/naver_logo.png" /></a>
172
+ </p>
173
+