Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5
Angular wrapper around the Muuri JavaScript library
License
dennisameling/muuri-angular
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Angular wrapper around theMuuri JavaScript library.Only supported on Angular 9 and newer versions.
Do you have any requests or improvements? Feel free to create an issue or PR.
Install the library with the following commands:
npm install --save muuri muuri-angular
AddMuuriModule
as an import to yourapp.module.ts
:
import{MuuriModule}from'muuri-angular';@NgModule({declarations:[...],imports:[ ...MuuriModule],providers:[],bootstrap:[...]})exportclassAppModule{}
app.component.html
<buttonid="add-item-button"(click)="addToGrid()">+ Add new block</button><br><br><div#gridclass="grid"muuriGrid[config]="layoutConfig"><divclass="grid-item"muuriGridItem*ngFor="let item of blockItems"><divclass="grid-item-content"> {{ item }}</div></div></div>
app.component.ts
import{Component}from'@angular/core';import{GridOptions}from'muuri';@Component({selector:'app-root',templateUrl:'./app.component.html',styleUrls:['./app.component.scss']})exportclassAppComponent{blockItems:string[]=['test','test2'];// Add any options you'd like to set herepubliclayoutConfig:GridOptions={items:[],layoutOnInit:false,dragEnabled:true,layout:{fillGaps:true,horizontal:false,alignRight:false,alignBottom:false,rounding:true}};addToGrid(){this.blockItems.push('hello');}}
Muuri exposes manyevents that you can subscribe to. You can get theGrid
object as follows:
app.component.html
<divmuuriGrid(gridCreated)="onGridCreated($event)"></div>
app.component.ts
importGridfrom'muuri';onGridCreated(grid:Grid){/** * Now you can do everything you want with the Grid object, * like subcribing to Muuri's events */grid.on('add',function(items){console.log(items);});}
You can also get a grid item when it is created:
app.component.html
<divmuuriGridItem(itemCreated)="onItemCreated($event)"></div>
app.component.ts
importItemfrom'muuri';onItemCreated(item:Item){// Now you can do anything you want with the grid item}
If you want to help developing this library, please do the following to set up your local environment:
- Set up a project that uses
muuri-angular
as a dependency. - Clone this repo (
muuri-angular
). - Run
npm install
. - Run
npm run build:ivy
. This will build an Ivy-compatible library that you can use in Angular 9+ projects locally.- If you're still using Angular 8 or lower in your project, run
npm run build:prod
instead. This will use Angular's legacy View Engine to build the library.
- If you're still using Angular 8 or lower in your project, run
- Run
cd dist/muuri-angular
. - Run
npm link
. - In your project, run
npm link muuri-angular
. Your project will now use the localmuuri-angular
code. - Run
npm run build:ivy -- --watch
so that the library gets rebuilt on every code change 😃
About
Angular wrapper around the Muuri JavaScript library
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.