Skip to content

Commit 78b5aa5

Browse files
author
rakeshAlgo
committed
Remove dropdown menu while click on tabs
1 parent c908e8e commit 78b5aa5

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/js/05-tabset.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
var hash = window.location.hash
2-
// var smallBreak = 768 // Your small screen breakpoint in pixels
2+
var queueData = []
3+
var checkActiveClass
4+
var tabOnLargeScreen = 3 // Display tab on desktop
5+
var tabOnSmallScreen = 1 // display tab on mobile view bewlow 768px screen
6+
var smallBreak = 768 // Your small screen breakpoint in pixels
37
find('.doc .tabset').forEach(function (tabset) {
48
var active
5-
var queueData = []
6-
var checkActiveClass
7-
var tabOnLargeScreen = 3 // Display tab on desktop
8-
var tabOnSmallScreen = 1 // display tab on mobile view bewlow 768px screen
9-
var smallBreak = 768
109
var tabs = tabset.querySelector('.tabs')
1110
if (tabs) {
1211
var first
1312
find('li', tabs).forEach(function (tab, idx) {
1413
var id = (tab.querySelector('a[id]') || tab).id
15-
// console.log(tab)
1614
checkActiveClass = setTimeout(function () {
1715
var activeTabList = tab.classList.contains('is-active')
1816
if (activeTabList) {
@@ -38,13 +36,11 @@ find('.doc .tabset').forEach(function (tabset) {
3836
}
3937
}, 100)
4038
if (window.innerWidth < smallBreak) {
41-
console.log('mobile view')
4239
if (idx > (tabOnSmallScreen - 1)) {
4340
queueData.push(tab)
4441
}
4542
} else {
4643
if (idx > (tabOnLargeScreen - 1)) {
47-
console.log('desktop view')
4844
queueData.push(tab)
4945
}
5046
}
@@ -82,18 +78,17 @@ function activateTab (e) {
8278
e.preventDefault()
8379
var tab = this.tab
8480
var pane = this.pane
85-
var dropdownMenu = document.querySelector('.tabs ul')
86-
// var dropdownBtnIcon = document.querySelector('.dropdown-btn-down .fas')
81+
var tabMenu= document.querySelector('.tabs ul')
8782
var nodeTab = document.querySelector('.tabs > ul')
8883
var nodeDropdownTabNode = document.querySelector('.other-tablist')
8984
if (tab.parentNode.classList[0] === 'other-tablist') {
9085
nodeDropdownTabNode.appendChild(nodeTab.lastElementChild)
9186
nodeTab.appendChild(tab)
87+
nodeDropdownTabNode.classList.remove('show')
9288
}
9389
var activeTabList = tab.classList.contains('is-active')
94-
// console.log(activeTabList, 127)
9590
if (activeTabList) {
96-
dropdownMenu.classList.remove('show')
91+
tabMenu.classList.remove('show')
9792
}
9893

9994
find('.tabs li, .tab-pane', this.tabset).forEach(function (it) {

0 commit comments

Comments
 (0)