mixinmax / jquery.swatches

A jQuery plugin that turns a one-line div into a sweet color swatch
http://maxmackie.github.io/jquery.swatches/
243 stars 26 forks source link

Don't re-render when calling swatchify multiple times #12

Open tatemz opened 9 years ago

tatemz commented 9 years ago

When I have a <div class="swatch"> and I run $('.swatch').swatchify(); multiple times on the same DOM element, multiple swatches are produced. Would be great if swatchify() checked if the DOM element has already rendered color swatches to avoid cloning swatches.

Additionally, it would be ideal to have the DOM element recalculated to take changes to the data-colors attribute into account. This may hinder performance, so perhaps a swatchify( recalculate = true/false ) might be advisable.

mixinmax commented 9 years ago

I agree with everything you've said. Unfortunately, I don't have much time to actively support this plugin anymore - but will gladly accept a working pull request :)

tatemz commented 9 years ago

Will do! :+1: