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

How to refresh items if delete any single or multiple items from list ? #28

Open
MrShaikh01 opened this issue Jun 19, 2020 · 2 comments

Comments

@MrShaikh01
Copy link

No description provided.

@schlosser
Copy link
Owner

This library doesn't support re-laying-out while already initialized. I would recommend showing a spinner on the screen, calling disable() and deleting the Pig instance, and then initialize another new Pig() with updated imageData.

@BePo65
Copy link
Contributor

BePo65 commented Nov 8, 2021

I am working on a page that loads the image list asynchronously from a REST server and wanted to initialize the pig element when the web page initializes and then set the data source when the data is available.
To achieve this it would be enough to add the following 2 methods to pig.js:

setImageData(imageData) {
  this.images = this._parseImageData(imageData);
}

clearImageData() {
  this.images.forEach(image => {
    if (image.existsOnPage) {
      image.hide();
    }
  });
  this.images = this._parseImageData([]);
  this.container.style.height = 'auto';
}

To show the new data, when they get available, I use these lines:

pig.disable();
pig.clearImageData();
pig.setImageData(serverResponseData);
pig.enable();

Seems not to complicated and IMHO would be a nice addition to this great project. Or is this just a complicated way of creating a new pig instance (but I had to remove the images already on the screen anyway).

Besides this, when working on this topic, I stumbled across a property of the pig class: visibleImages. I didn't find any references to this property.
Is this just a remnant of an older version? Or did I just not look thoroughly enough?

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

3 participants