From c9da85f4db71cccbaf2f16a774bd9b734d1db3d0 Mon Sep 17 00:00:00 2001 From: Cox Chen Date: Wed, 3 Apr 2013 22:55:18 +0800 Subject: [PATCH] Fixed a bug in Segmented controller when swapping content sections back and forth --- lib/js/segmented-controllers.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/js/segmented-controllers.js b/lib/js/segmented-controllers.js index 6c1111d..8f785d9 100644 --- a/lib/js/segmented-controllers.js +++ b/lib/js/segmented-controllers.js @@ -14,7 +14,7 @@ window.addEventListener("touchend", function (e) { var activeTab; - var activeBody; + var activeBodies; var targetBody; var targetTab; var className = 'active'; @@ -36,9 +36,13 @@ if (!targetBody) return; - activeBody = targetBody.parentNode.querySelector(classSelector); + activeBodies = targetBody.parentNode.querySelectorAll(classSelector); - if (activeBody) activeBody.classList.remove(className); + if (activeBodies) { + for (var i = 0; i < activeBodies.length; i++){ + activeBodies[i].classList.remove(className); + } + } targetBody.classList.add(className) });