@egjs/ngx-infinitegrid
v4.12.0
Published
An Angular component that can arrange items infinitely according to the type of grids
Downloads
191
Keywords
Readme
⚙️ Installation
npm install @egjs/ngx-infinitegrid
# Or if you're using yarn
yarn add @egjs/ngx-infinitegrid
🏃 Quick Start
Module definition
+import { NgxInfiniteGridModule } from '@egjs/ngx-infinitegrid';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
+ NgxInfiniteGridModule /* Add in imports */
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {} /* Your app */
<div
NgxMasonryInfiniteGrid
class="container"
[gap]="5"
[items]="items"
[trackBy]="trackBy"
[groupBy]="groupBy"
(requestAppend)="onRequestAppend($event)"
*ngFor="let item of [0]; trackBy: randomTrackBy"
#ig
>
<div
class="item"
*ngFor="let item of ig.visibleItems; trackBy: trackBy;"
></div>
</div>
import { Component, Input } from '@angular/core';
import { OnRequestAppend } from '@egjs/infinitegrid';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
items = this.getItems(0, 10);
getItems(nextGroupKey: number, count: number) {
const nextItems = [];
const nextKey = nextGroupKey * count;
for (let i = 0; i < count; ++i) {
nextItems.push({ groupKey: nextGroupKey, key: nextKey + i });
}
return nextItems;
}
groupBy(_: any, item: any) {
return item.groupKey;
}
trackBy(_: any, item: any) {
return item.key;
}
onRequestAppend(e: OnRequestAppend) {
const nextGroupKey = (+e.groupKey! || 0) + 1;
this.items = [...this.items, ...this.getItems(nextGroupKey, 10)];
}
}
📖 More Options & Examples
🙌 Contributing
See CONTRIBUTING.md
📝 Feedback
Please file an Issue with label "Angular".
Local development
Project setup
npm install
Compiles and hot-reloads demo
npm run start
Compiles and minifies for production
npm run build
Run your tests
npm run test
Lints and fixes files
npm run lint
📜 License
egjs-infinitegrid is released under the MIT license.
Copyright (c) 2015-present NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.