해당 영역으로 스크롤 이동
const makeArray = (arrayLikeObject) => {
return Array.from(arrayLikeObject)
}
const buttonList = document.querySelectorAll('.scrollView__controlTab')
const sceneList = document.querySelectorAll('.scrollView__scene')
const arrButton = makeArray(buttonList)
const handelScrollButton = function (index) {
// 클로저를 사용
return function (e) {
e.preventDefault()
sceneList[index].scrollIntoView({ behavior: 'smooth' })
}
}
arrButton.forEach((item, index) => {
item.addEventListener('click', handelScrollButton(index))
})
참고
Last updated