switchery
switchery copied to clipboard
Changing switch state from js fails if hidden
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;
};
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.