2026-02-17 17:53:00 +01:00
|
|
|
// Main JavaScript file for Palina theme
|
2026-02-19 18:07:46 +01:00
|
|
|
// Using HTMX and Alpine.js for enhanced functionality
|
|
|
|
|
|
2026-02-17 17:53:00 +01:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
console.log('Palina theme loaded!');
|
|
|
|
|
|
2026-02-19 18:07:46 +01:00
|
|
|
// Staggered fade-in animation for post grid
|
|
|
|
|
const animateGridItems = (container = document) => {
|
|
|
|
|
const gridItems = container.querySelectorAll('.post-grid-item:not(.animated)');
|
|
|
|
|
gridItems.forEach((item, index) => {
|
|
|
|
|
item.style.animationDelay = `${index * 100}ms`;
|
|
|
|
|
item.classList.add('animate-fadeInUp');
|
|
|
|
|
item.classList.add('animated');
|
2026-02-17 18:29:09 +01:00
|
|
|
});
|
2026-02-17 20:12:45 +01:00
|
|
|
};
|
2026-02-17 18:54:09 +01:00
|
|
|
|
2026-02-19 18:07:46 +01:00
|
|
|
// Initial animation
|
|
|
|
|
animateGridItems();
|
2026-02-17 19:07:11 +01:00
|
|
|
|
2026-02-19 18:07:46 +01:00
|
|
|
// Re-run animation and other setup when HTMX settles new content
|
2026-02-19 20:03:51 +01:00
|
|
|
// Use document instead of document.body to persist across boosted navigation
|
|
|
|
|
document.addEventListener('htmx:afterSettle', (event) => {
|
2026-02-19 18:07:46 +01:00
|
|
|
// If the settled element is the posts-container or contains grid items
|
2026-02-19 20:03:51 +01:00
|
|
|
const target = event.detail.target;
|
|
|
|
|
if (target.id === 'posts-container' || target.querySelector('.post-grid-item')) {
|
|
|
|
|
animateGridItems(target);
|
2026-02-17 19:07:11 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-19 20:03:51 +01:00
|
|
|
// Handle global boost re-animation
|
2026-02-19 18:07:46 +01:00
|
|
|
if (event.detail.boosted) {
|
|
|
|
|
animateGridItems();
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-02-17 17:53:00 +01:00
|
|
|
});
|