Skip to content

Commit

Permalink
scrolling buttons hide
Browse files Browse the repository at this point in the history
  • Loading branch information
terpimost committed Nov 10, 2023
1 parent a20a6e9 commit e703bea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 23 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -650,25 +650,44 @@ <h4>Enterprise</h4>
tabButton.addEventListener('keydown', onTabButtonKeydownClick)
})

const pricing_tabs = document.querySelector('.pricing-tabs')
function onPlansScrollLeft() {
const sectionWidth = document.querySelector('.pricing-tab._active .plan-section')?.clientWidth - 12
document.querySelector('.pricing-tabs').scrollBy({
pricing_tabs.scrollBy({
top: 0,
left: -sectionWidth,
behavior: 'smooth'
})
}
document.getElementById('plans-left-button').addEventListener('click', onPlansScrollLeft)
const plans_left_button = document.getElementById('plans-left-button')
plans_left_button.addEventListener('click', onPlansScrollLeft)

function onPlansScrollRight() {
const sectionWidth = document.querySelector('.pricing-tab._active .plan-section')?.clientWidth - 12
document.querySelector('.pricing-tabs').scrollBy({
pricing_tabs.scrollBy({
top: 0,
left: sectionWidth,
behavior: 'smooth'
})
}
document.getElementById('plans-right-button').addEventListener('click', onPlansScrollRight)
const plans_right_button = document.getElementById('plans-right-button')
plans_right_button.addEventListener('click', onPlansScrollRight)

function onPlansScroll() {
if (pricing_tabs.scrollLeft <= 8) {
plans_left_button.classList.add('_hidden')
} else {
plans_left_button.classList.remove('_hidden')
}

if (pricing_tabs.scrollLeft <= pricing_tabs.scrollWidth - pricing_tabs.clientWidth - 8) {
plans_right_button.classList.remove('_hidden')
} else {
plans_right_button.classList.add('_hidden')
}
}
onPlansScroll()
pricing_tabs.addEventListener('scroll', onPlansScroll)

</script>
</body>
Expand Down
4 changes: 4 additions & 0 deletions plans.css
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ a.neworg-button:active {
#plans-right-button {
display: block;
}
#plans-left-button._hidden,
#plans-right-button._hidden{
display: none;
}

}

Expand Down

0 comments on commit e703bea

Please sign in to comment.