switchery icon indicating copy to clipboard operation
switchery copied to clipboard

Changing switch state from js fails if hidden

Open oxxido opened this issue 10 years ago • 1 comments

I took the approach from #25 as @guillerodriguez said, but marking down fails if switches are hidden.

The problem is that in colorize function, this.switcher.offsetHeight returns 0, I solved that changing one line

var height = this.switcher.offsetHeight || 32;

So function was

 Switchery.prototype.colorize = function() {
   var height = this.switcher.offsetHeight || 32;
   var switcherHeight = height / 2;

   this.switcher.style.backgroundColor = this.options.color;
   this.switcher.style.borderColor = this.options.color;
   this.switcher.style.boxShadow = 'inset 0 0 0 ' + switcherHeight + 'px ' + this.options.color;
   this.jack.style.backgroundColor = this.options.jackColor;
 };

oxxido avatar Apr 07 '15 18:04 oxxido

I can help you, but I can't reproduce the issue. Can you provide a working example in JSfiddle, CodePen or another similar site? I want to see how exactly are you hiding the switches.

abpetkov avatar Apr 08 '15 07:04 abpetkov