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

clusterize.update() fails when there are repeated items #126

Closed
ojvribeiro opened this issue Nov 1, 2017 · 7 comments
Closed

clusterize.update() fails when there are repeated items #126

ojvribeiro opened this issue Nov 1, 2017 · 7 comments

Comments

@ojvribeiro
Copy link

ojvribeiro commented Nov 1, 2017

Hey!

I want to remove some items from a list using JavaScript's .splice() method. I also use a for loop to update some items informations before calling clusterize.update().

It goes fine when there are diferent items in the list and if the viewport is at the end of the list (even if the item repeats), but clusterize.update() fails when there are repeated items in the cluster AND if the viewport is not at the end of the list.

In this gif you can understand me better:
https://gfycat.com/gifs/detail/RewardingUglyBongo

@NeXTs
Copy link
Owner

NeXTs commented Nov 2, 2017

Hello

Could you provide some demo on codepen?

@ojvribeiro
Copy link
Author

ojvribeiro commented Nov 2, 2017

Here's the pen:
https://codepen.io/ovictorribeiro/pen/xPZrwo

@NeXTs
Copy link
Owner

NeXTs commented Nov 3, 2017

thanks

ok, so this happens because after deletion you send EXACT same layout of current cluster.
clusterize has additional check to prevent unnecessary updates if layout wasn't changed

the only difference between rows after row number 80 is numbers. but after deletion you restoring numbers of subsequent rows. layout stored in clusterize cache and updated layout for current cluster are equal, that's why this condition fails for your case.

what you can do:

  1. dirty but quick workaround.
    after deletion - change your list at least somehow to give a hint for clusterize to update list.
    here I've added data-update attribute, data property increments on every deletion so this should help.
    https://codepen.io/NeXTs/pen/rYxpbm?editors=1010

  2. Wait until I publish update for clusterize (day or two) that would allow you to use pure css counters.

@ojvribeiro
Copy link
Author

ojvribeiro commented Nov 3, 2017

Oh thank you very much for the workaround and for the explanation (thanks for the redundance tip too).

I'll implement your solution. I'll wait for the update, though.

@NeXTs
Copy link
Owner

NeXTs commented Nov 3, 2017

Hey @jvribeiro
see demo of "Ordered list" + explanation in FAQ

@ojvribeiro
Copy link
Author

ojvribeiro commented Nov 4, 2017

Cool! That was pretty fast.

@FeehGb
Copy link

FeehGb commented Mar 20, 2020

case Nothing change, could return something in callback ?

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