bootstrap-colorpickersliders icon indicating copy to clipboard operation
bootstrap-colorpickersliders copied to clipboard

ColorPickerSliders and Bootstrap.js ver 3.3.2 issues

Open rollout123 opened this issue 9 years ago • 2 comments

There are strange behaviors with bootstrap-colorpickersliders and the latest (as of this date) version of Bootstrap.js (ver. 3.3.2) When using 3.3.2 instead of the included 3.0.3, colorpickersliders.js is writing 4, 8 or more copies of the current color to the localstorage, and displaying all these extra copies in the swatches palette when saving a color to the palette.

swathes-error1

rollout123 avatar Mar 16 '15 19:03 rollout123

On version 3.3.6 of Bootstrap.js it will save 8 copies on the first time and as many as it can save on the second, freezing the browser.

Edit: It seems every time you switch tabs, _bindControllerEvents() is called and it goes multiplying on each click.

aini-naire avatar May 01 '16 19:05 aini-naire

This can be fixed by just changing the bootstrap.colorpickersliders.js as follows: Tested for bootstrap 3.3.7

NEED TO CHANGE:

  elements.swatches.on('touchstart mousedown click', 'li span', function(ev) {
          var color = $(this).css('background-color');
          updateColor(color);
          //_updateAllElements();
          ev.preventDefault();
        });

        elements.swatches_add.on('touchstart mousedown click', function(ev) {
          _addCurrentColorToSwatches();
          ev.preventDefault();
          ev.stopPropagation();
        });

CHANGE IT TO:

  elements.swatches.on('touchstart click', 'li span', function(ev) {
          var color = $(this).css('background-color');
          updateColor(color);
          //_updateAllElements();
          ev.preventDefault();
        });

 elements.swatches_add.on('touchstart click', function(ev) {
            if (ev.type === 'click' || ev.type === 'touchstart')  
            {
                _addCurrentColorToSwatches();
            }
          ev.preventDefault();
          ev.stopImmediatePropagation();
        });

sundasa avatar Oct 19 '16 13:10 sundasa