Dieter
Dieter

Reputation: 31

how can I add ui.ColorPalette to ui.Halo

How can I add an ui.ColorPalette to a customized ui.Halo handle? The halo icon should show the first color from the ColorPalette.

I am using Rappid.

Thanks

Upvotes: 0

Views: 160

Answers (1)

Dieter
Dieter

Reputation: 31

I found a solution. Maybe someone can look at the code and tell if the solution is correct and give a better solution on how to get the halo handle (l_target). Thanks Dieter

 //this is my halo handle
  var l_target  = document.getElementsByClassName('handle mycolor se');
  var l_fill = cellView.model.attr ('rect/fill');
  var l_content = [
     {content: '#ccff99'},
     {content: '#B3B3B3'},
     {content: '#808080'},
     {content: '#4D4D4D'},
     {content: '#E6E6E6'},
     {content: '#FFC7C9'},
     {content: '#FFA0A4'},
     {content: '#E3686D'}
   ];
  var l_selected = l_content.findIndex (c => c.content === l_fill);

  m_colorPalette = new joint.ui.ColorPalette({
    options: l_content,
    selected: l_selected
  });

  m_colorPalette.on ('option:select', function (element) {

    cellView.model.attr ('rect/fill', element.content);

  });
  m_colorPalette.render().el;

  l_target [0].appendChild (m_colorPalette.render().el);

halo with colorpalette

Upvotes: 1

Related Questions