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

Loading…
Cancel
Save