From d7ee6a8a5ae1ad8cae643f51bf9a4ed45b7eccee Mon Sep 17 00:00:00 2001 From: Vincent Wang Date: Thu, 18 Dec 2014 21:50:56 +0800 Subject: [PATCH] keep container div's width under select mode under select mode, the container div's width may be changed, fix this issue --- toggles.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/toggles.js b/toggles.js index 0fe7799..978051c 100644 --- a/toggles.js +++ b/toggles.js @@ -105,10 +105,10 @@ Toggles.prototype.createEl = function() { blob: div('blob') }; - var halfHeight = height / 2; - var onOffWidth = width - halfHeight; - var isSelect = self.selectType; + + var halfHeight = height / 2; + var onOffWidth = isSelect ? width/2 : width - halfHeight; // set up the CSS for the individual elements self.els.on @@ -138,13 +138,13 @@ Toggles.prototype.createEl = function() { }); self.els.inner.css({ - width: width * 2 - height, + width: isSelect ? width : width * 2 - height, marginLeft: (isSelect || self['active']) ? 0 : -width + height }); - if (self.selectType) { + if (isSelect) { self.els.slide.addClass('toggle-select'); - self.el.css('width', onOffWidth * 2); + self.el.css('width', width); self.els.blob.hide(); }