Browse Source

Fixed "active" class bug with toggle

If there was a toggle element within a segmented control, they would all have their "active" class removed.
pull/839/head
thewax 8 years ago committed by GitHub
parent
commit
790d5300b0
  1. 19
      js/segmented-controllers.js

19
js/segmented-controllers.js

@ -21,20 +21,20 @@
}
}
};
window.addEventListener('touchend', function (e) {
var tabTouchEnd = function (e) {
var activeTab;
var activeBodies;
var targetBody;
var targetTab = getTarget(e.target);
var className = 'active';
var classSelector = '.' + className;
var classSelector = '.control-content.active';
var tabClassSelector = '.control-item.active';
if (!targetTab) {
return;
}
activeTab = targetTab.parentNode.querySelector(classSelector);
activeTab = targetTab.parentNode.querySelector(tabClassSelector);
if (activeTab) {
activeTab.classList.remove(className);
@ -59,12 +59,9 @@
}
targetBody.classList.add(className);
});
window.addEventListener('click', function (e) {
if (getTarget(e.target)) {
e.preventDefault();
}
});
};
window.addEventListener('touchend', tabTouchEnd);
window.addEventListener("MSPointerUp", tabTouchEnd);
window.addEventListener('click', function (e) { if (getTarget(e.target)) { preventDef(e); } });
}());

Loading…
Cancel
Save