generated from HugoBlox/theme-academic-cv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5db3d64
commit 846e669
Showing
4 changed files
with
27 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
console.log('Custom script loaded'); | ||
|
||
function smoothScroll(e) { | ||
const href = this.getAttribute('href'); | ||
console.log('Clicked link:', href); | ||
|
||
if (href.startsWith('/#')) { | ||
window.addEventListener('load', function() { | ||
console.log('Custom script loaded'); | ||
|
||
function smoothScroll(e) { | ||
const href = this.getAttribute('href'); | ||
console.log('Clicked link:', href); | ||
|
||
if (href.startsWith('/#')) { | ||
e.preventDefault(); | ||
console.log('Preventing default behavior for:', href); | ||
|
||
const targetId = href.replace('/#', ''); | ||
const targetElement = document.getElementById(targetId); | ||
|
||
if (targetElement) { | ||
console.log('Scrolling to:', targetId); | ||
targetElement.scrollIntoView({ | ||
behavior: 'smooth' | ||
}); | ||
console.log('Scrolling to:', targetId); | ||
targetElement.scrollIntoView({ | ||
behavior: 'smooth' | ||
}); | ||
} else { | ||
console.log('Target element not found:', targetId); | ||
console.log('Target element not found:', targetId); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function attachSmoothScroll() { | ||
console.log('Attaching smooth scroll'); | ||
|
||
const menuLinks = document.querySelectorAll('a[href^="/#"]'); | ||
console.log('Found menu links:', menuLinks.length); | ||
|
||
menuLinks.forEach(link => { | ||
console.log('Adding listener to:', link.href); | ||
link.addEventListener('click', smoothScroll); | ||
console.log('Adding listener to:', link.href); | ||
link.addEventListener('click', smoothScroll); | ||
}); | ||
} | ||
|
||
// Try to attach immediately | ||
attachSmoothScroll(); | ||
|
||
// Also attach when the DOM is fully loaded | ||
document.addEventListener('DOMContentLoaded', attachSmoothScroll); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
{{ $custom_js := resources.Get "js/custom.js" | js.Build "custom.js" }} | ||
<script src="{{ $custom_js.RelPermalink }}"></script> | ||
<script>console.log('This is a test');</script> |
This file was deleted.
Oops, something went wrong.