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
JVRibeiro opened this Issue Nov 1, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@JVRibeiro

JVRibeiro commented Nov 1, 2017

Hey!

I'm creating a web app that uses Clusterize. Very cool plugin by the way. ;)

My issue is when I want to remove some of its items through the app itself 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 repeated), but clusterize.update() fails if 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

My english is still a work in progress. Corrections are welcomed. :)

@NeXTs

This comment has been minimized.

Show comment
Hide comment
@NeXTs

NeXTs Nov 2, 2017

Owner

Hello

Could you provide some demo on codepen?

Owner

NeXTs commented Nov 2, 2017

Hello

Could you provide some demo on codepen?

@JVRibeiro

This comment has been minimized.

Show comment
Hide comment
@JVRibeiro

JVRibeiro Nov 2, 2017

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

I also made a special console to help you to help me. haha

JVRibeiro commented Nov 2, 2017

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

I also made a special console to help you to help me. haha

@NeXTs

This comment has been minimized.

Show comment
Hide comment
@NeXTs

NeXTs Nov 3, 2017

Owner

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.

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.

@JVRibeiro

This comment has been minimized.

Show comment
Hide comment
@JVRibeiro

JVRibeiro Nov 3, 2017

Oh thank you very much for the workaround and for the explanation (thanks for the redundance tip too, I'm not an example of good programmer).

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

JVRibeiro commented Nov 3, 2017

Oh thank you very much for the workaround and for the explanation (thanks for the redundance tip too, I'm not an example of good programmer).

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

@NeXTs

This comment has been minimized.

Show comment
Hide comment
@NeXTs

NeXTs Nov 3, 2017

Owner

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

Owner

NeXTs commented Nov 3, 2017

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

@JVRibeiro

This comment has been minimized.

Show comment
Hide comment
@JVRibeiro

JVRibeiro Nov 4, 2017

Cool! That was pretty fast.

JVRibeiro commented Nov 4, 2017

Cool! That was pretty fast.

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