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

Using the reloadItems function #52

Open
sknoth opened this issue May 12, 2017 · 0 comments
Open

Using the reloadItems function #52

sknoth opened this issue May 12, 2017 · 0 comments

Comments

@sknoth
Copy link

sknoth commented May 12, 2017

Hi,
i am using the masonry grid in an angular 4 project and am adding more items when the user scrolls. Most of the times it is working, but sometimes it seems that not all new items get added to the layout correctly. I use a counter to make sure that all items have been added to the layout before allowing to load more items through scrolling to prevent issues with "cannot remove node" that are also mentioned here in the forum.

ngAfterViewInit() {
   // gets called for every object
   this.masonry.layoutComplete.subscribe((items) => {
     this.itemsAddedToLayout++;
  });
}

...

@HostListener("window:scroll", [])
onWindowScroll(event) {
  if (this.itemsAddedToLayout >= this.itemsToLoad
     && window.scrollY > document.body.offsetHeight - window.innerHeight - 300) {
     this.addMoreProducts();
   }
}

Also what items are shown can be changed by the user through various filtering options.

Therefore I thought one possible solution might be to use the reloadItems() function by the original script, but I don't know how I can access it since it does not seem to be supported by this port of the masonry script.

Any hints or pointers in the right direction would be greatly appreciated.

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

No branches or pull requests

1 participant