jaames/iro.js

Anyway to remove a `iro.ColorPicker` instance?

rockwellll opened this issue · 1 comments

hi. So, i looked at the docs and the advanced usage section but could not find it. Maybe i'm just blind. But.

Is there any way to remote the iro.ColorPicker instance programatically. Something like colorPicker.remove()?. The issue i'm having is that i'm cloning an element that has the colorpicker as a child. But, the cloned element's colorPicker does not work.

  replaceWithSynced() {
    const element = Array.from(document.querySelectorAll(`[data-hero-id=${this.element.dataset.heroId}]`))
      .find((layoutSection) => layoutSection !== this.element)

    setTimeout(() => {
      this.element.replaceWith(element.cloneNode(true))
    }, 10)
  }
Screen.Recording.2022-03-03.at.16.21.56.mov

The "left" colorPicker is from the clonedNode, i.e (element.cloneNode(true) and the right colorPicker is the original one.

Thank you for this gem of a package!. Best.

cloneNode isn't going to copy JS interactivity which is why the cloned picker won't work. You'd have to select the cloned color picker element and create a new ColorPicker instance on it