Skip to content

Commit

Permalink
adding wire:navigate to backing to welcome page
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles committed Jul 2, 2024
1 parent c7e16e2 commit 48e003e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
47 changes: 24 additions & 23 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@ document.addEventListener('alpine:init', () => {
});

/* smooth navigation */
document.addEventListener('livewire:init', () => {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault()

const hash = this.getAttribute('href')

document.querySelector(hash)?.scrollIntoView({
behavior: 'smooth'
})

history.pushState(null, null, hash)
})
})

const hash = window.location.hash

if (hash) {
document.querySelector(hash)?.scrollIntoView({
behavior: 'smooth'
})
}
})
// disabled when wire:navigate was enabled
// document.addEventListener('livewire:init', () => {
// document.querySelectorAll('a[href^="#"]').forEach(anchor => {
// anchor.addEventListener('click', function (e) {
// e.preventDefault()
//
// const hash = this.getAttribute('href')
//
// document.querySelector(hash)?.scrollIntoView({
// behavior: 'smooth'
// })
//
// history.pushState(null, null, hash)
// })
// })
//
// const hash = window.location.hash
//
// if (hash) {
// document.querySelector(hash)?.scrollIntoView({
// behavior: 'smooth'
// })
// }
// })

/* algolia */
docsearch({
Expand Down
Loading

0 comments on commit 48e003e

Please sign in to comment.