Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Angular wrapper around the Muuri JavaScript library

License

NotificationsYou must be signed in to change notification settings

dennisameling/muuri-angular

Repository files navigation

npm version

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.

Getting started

Install the library with the following commands:

npm install --save muuri muuri-angular

Basic Usage

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');}}

Advanced usage

Events

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}

Contributing

If you want to help developing this library, please do the following to set up your local environment:

  • Set up a project that usesmuuri-angular as a dependency.
  • Clone this repo (muuri-angular).
  • Runnpm install.
  • Runnpm 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, runnpm run build:prod instead. This will use Angular's legacy View Engine to build the library.
  • Runcd dist/muuri-angular.
  • Runnpm link.
  • In your project, runnpm link muuri-angular. Your project will now use the localmuuri-angular code.
  • Runnpm run build:ivy -- --watch so that the library gets rebuilt on every code change 😃

About

Angular wrapper around the Muuri JavaScript library

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp