Spaces:
Running
Running
File size: 1,046 Bytes
11bf4da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Copy code snippets functionality
document.querySelectorAll('code').forEach(code => {
code.addEventListener('click', () => {
const text = code.innerText;
navigator.clipboard.writeText(text).then(() => {
const originalText = code.innerText;
code.innerText = 'Copied!';
setTimeout(() => {
code.innerText = originalText;
}, 2000);
});
});
});
// Responsive adjustments
function handleResize() {
const main = document.querySelector('main');
if (window.innerWidth < 768) {
main.classList.add('px-2');
} else {
main.classList.remove('px-2');
}
}
window.addEventListener('resize', handleResize);
handleResize(); |