Files
aperonight/app/javascript/controllers/featured_event_controller.js
Kevin BATAILLE 30f3ecc6ad refactor(events): replace parties concept with events throughout the application
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

This commit refactors the entire application to replace the 'parties' concept with 'events'. All controllers, models, views, and related files have been updated to reflect this change. The parties table has been replaced with an events table, and all related functionality has been updated accordingly.
2025-08-28 13:20:51 +02:00

86 lines
2.3 KiB
JavaScript
Executable File

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["card"]
static classes = ["visible"]
static values = {
threshold: { type: Number, default: 0.1 },
rootMargin: { type: String, default: '0px 0px -50px 0px' },
staggerDelay: { type: Number, default: 0.2 }
}
connect() {
console.log("FeaturedEventController connected")
this.setupIntersectionObserver()
this.setupStaggeredAnimations()
}
disconnect() {
if (this.observer) {
this.observer.disconnect()
}
}
setupIntersectionObserver() {
const observerOptions = {
threshold: this.thresholdValue,
rootMargin: this.rootMarginValue
}
this.observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible')
}
})
}, observerOptions)
// Observe all card elements within this controller's scope
const elements = this.cardTargets
console.log("Card targets:", elements)
elements.forEach(el => {
this.observer.observe(el)
})
}
setupStaggeredAnimations() {
console.log("Setting up staggered animations")
console.log("Card targets:", this.cardTargets)
// Add staggered animation delays to cards
this.cardTargets.forEach((card, index) => {
card.style.transitionDelay = `${index * this.staggerDelayValue}s`
card.classList.remove('visible')
})
}
}
/** Old code
<script>
// Add animation classes when elements are in view
document.addEventListener("DOMContentLoaded", function() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// Observe animated elements
document.querySelectorAll('.animate-fadeInUp, .animate-slideInLeft, .animate-slideInRight').forEach(el => {
observer.observe(el);
});
// Add staggered animation delays
document.querySelectorAll('.featured-event-card').forEach((card, index) => {
card.style.transitionDelay = `${index * 0.2}s`;
});
});
</script>
*/