Skip to content
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

Gridster options: dragAndDrop is breaking the app #41

Closed
GabrielGamy opened this issue May 10, 2017 · 2 comments
Closed

Gridster options: dragAndDrop is breaking the app #41

GabrielGamy opened this issue May 10, 2017 · 2 comments
Assignees

Comments

@GabrielGamy
Copy link

I set the dragAndDrop option to false, and when I navigate to a new page my app breaks.

gridsterOptions:IGridsterOptions = {
lanes: 5,
direction: "vertical",
dragAndDrop: false
}

I found this into the gridster-item.component.ts class:

this.dragSubscription is undefined but into the ngOnDestroy(), you try to unsubscribe on it

ngOnInit() {
    this.gridster.registerItem(this);

    if(this.gridster.options.dragAndDrop) {
        this.createMouseDrag(this.$element);
        this.createTouchDrag(this.$element);

        // Update position
        this.dragSubscription = this.dragging.subscribe((pos) => {
            if(!this.pin){
                this.$element.style.top = (pos.top - this.gridster.$element.offsetTop) + 'px';
                this.$element.style.left = (pos.left - this.gridster.$element.offsetLeft) + 'px';
            }           
        });
    }
}
ngOnDestroy() {
    let index = this.gridster.items.findIndex((z) => z == this);
    if(index){
        this.gridster.items.splice(index,1);
    }
    this.dragSubscription.unsubscribe();
}
@swiety85
Copy link
Owner

swiety85 commented May 16, 2017

I don't know which version of angular2gridster you use but the code of gridster-item.component.ts is different than code that you place in your comment.
Despite of this I've tried to reproduce this issue as you described but everything seams to work.
Please update your project to angular2gridster v. 0.5.2 and check again.

@GabrielGamy
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants