Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SWLab UI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
SWD
SWLab UI
Commits
b34b20f0
Commit
b34b20f0
authored
Oct 21, 2024
by
박민석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test nav
parent
c690adbf
Pipeline
#21604
passed with stages
in 3 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
01-nav.js
src/js/01-nav.js
+29
-18
No files found.
src/js/01-nav.js
View file @
b34b20f0
...
...
@@ -39,16 +39,16 @@
}
})
//
document.querySelectorAll('.nav-link').forEach(function (link) {
//
link.addEventListener('click', function (e) {
//
e.preventDefault() // 기본 링크 동작 방지
//
var parentToggle = link.closest('.nav-item').querySelector('.nav-item-toggle')
//
if (parentToggle) {
//
parentToggle.click() // 트리 토글
//
}
//
window.location.href = link.href // 첫 번째 링크로 이동
//
})
//
})
document
.
querySelectorAll
(
'.nav-link'
).
forEach
(
function
(
link
)
{
link
.
addEventListener
(
'click'
,
function
(
e
)
{
e
.
preventDefault
()
// 기본 링크 동작 방지
var
parentToggle
=
link
.
closest
(
'.nav-item'
).
querySelector
(
'.nav-item-toggle'
)
if
(
parentToggle
)
{
parentToggle
.
click
()
// 트리 토글
}
window
.
location
.
href
=
link
.
href
// 첫 번째 링크로 이동
})
})
if
(
navMenuToggle
&&
menuPanel
.
querySelector
(
'.nav-item-toggle'
))
{
navMenuToggle
.
style
.
display
=
''
...
...
@@ -120,7 +120,6 @@
}
}
var
navItem
console
.
log
(
navLink
)
if
(
navLink
)
{
navItem
=
navLink
.
parentNode
}
else
if
(
originalPageItem
)
{
...
...
@@ -128,13 +127,25 @@
}
else
{
return
}
if
(
navItem
===
currentPageItem
)
return
find
(
menuPanel
,
'.nav-item.is-active'
).
forEach
(
function
(
el
)
{
el
.
classList
.
remove
(
'is-active'
,
'is-current-path'
,
'is-current-page'
)
})
navItem
.
classList
.
add
(
'is-current-page'
)
currentPageItem
=
navItem
activateCurrentPath
(
navItem
)
// if (navItem === currentPageItem) return
// find(menuPanel, '.nav-item.is-active').forEach(function (el) {
// el.classList.remove('is-active', 'is-current-path', 'is-current-page')
// })
// navItem.classList.add('is-current-page')
// currentPageItem = navItem
// activateCurrentPath(navItem)
// 중복 펼침 방지
if
(
!
navItem
.
classList
.
contains
(
'is-current-page'
))
{
find
(
menuPanel
,
'.nav-item.is-active'
).
forEach
(
function
(
el
)
{
el
.
classList
.
remove
(
'is-active'
,
'is-current-path'
,
'is-current-page'
)
})
navItem
.
classList
.
add
(
'is-current-page'
)
currentPageItem
=
navItem
activateCurrentPath
(
navItem
)
}
scrollItemToMidpoint
(
menuPanel
,
navLink
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment