New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Events #4
Comments
@wSedlacek I just introduced an Events feature. It allows you to get the Grid object directly, so you can use it to subscribe to events etc. Would this work for you, or do you prefer to have it like you mentioned? <div muuriGrid (synchronize)="updateCachedGrid($event)"></div>
<div muuriGrid (add)="onAdd($event)"></div>
etc. In the library's internals it would then look something like export class MuuriGridDirective implements OnInit, OnDestroy {
...
@Output() synchronize: EventEmitter<void> = new EventEmitter();
@Output() layoutStart: EventEmitter<{items: Item[], isInstant: boolean}> = new EventEmitter();
@Output() add: EventEmitter<{items: Item[]}> = new EventEmitter();
etc.
...
constructor(private elRef: ElementRef) {}
ngOnInit(): void {
this.init(this.elRef);
}
/**
* Initialize the grid.
*/
init(grid: ElementRef): void {
this.gridObject = new Grid(grid.nativeElement, this.config);
this.gridObject.on('synchronize', () => this.synchronize.emit());
this.gridObject.on('layoutStart', (items, isInstant) => this.layoutStart.emit({items, isInstant}));
this.gridObject.on('add', (items) => this.add.emit({items}));
}
} ... which means that we have to keep track of all GridEvents, and when a new one is added in the main library, we'll need to add it as well. I'm happy to do that, but I just thought it'd be more efficient if the user can directly call Please let me know which option you prefer 😊 |
Being a wrapper for Muuri it would be best if abstracted to Angular conventions.
In any case that solution would be much more complex so perhaps for that reason alone the upkeep makes more sense. |
Muuri features many events, it would be great if these could be bound to using Angular event building.
https://github.com/haltu/muuri#grid-events
It may look something like this.
The text was updated successfully, but these errors were encountered: