{% extends 'backfront.html.twig' %}
{% block title %}Sessions de formation SIP Academy - Calendrier et inscription{% endblock %}
{% block meta_description %}
Inscrivez-vous aux prochaines sessions de formation chez SIP Academy. Consultez le calendrier de nos cours en ligne et en présentiel et planifiez votre avenir.
{% endblock %}
{% block body %}
<style>
/* ===== COULEURS MODERNES ===== */
:root {
--gold: #FFAE27;
--gold-dark: #e09500;
--gold-light: #fff8e6;
--navy: #1F3971;
--navy-dark: #162d5a;
--navy-light: #e8edf8;
--text-dark: #1a2a3a;
--text-muted: #6c757d;
--border-light: #eef2f6;
}
/* ===== BREADCRUMB MODERNE ===== */
.breadcrumb-area {
background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
padding: 100px 0 120px;
position: relative;
text-align: center;
}
.breadcrumb-title h1 {
color: #fff;
font-size: 48px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -1px;
}
.breadcrumb-list {
list-style: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
gap: 15px;
align-items: center;
}
.breadcrumb-list li, .breadcrumb-list li a {
color: rgba(255,255,255,0.7);
font-size: 15px;
text-decoration: none;
transition: color 0.3s;
}
.breadcrumb-list li a:hover {
color: var(--gold);
}
.breadcrumb-list li.active {
color: var(--gold);
}
.breadcrumb-list li i {
font-size: 14px;
color: var(--gold);
}
/* ===== SEARCH BAR FLOATING MODERNE ===== */
.search-category {
margin-top: -60px;
position: relative;
z-index: 10;
padding-bottom: 20px;
}
.search-wrapper-glass {
background: #ffffff;
padding: 30px;
border-radius: 24px;
box-shadow: 0 15px 35px rgba(0,0,0,0.1);
border: 1px solid rgba(255,255,255,0.8);
}
.form-container-modern {
display: grid;
grid-template-columns: 2fr 1fr 1fr auto;
gap: 15px;
align-items: center;
}
.input-group-custom {
position: relative;
display: flex;
align-items: center;
}
.input-group-custom i {
position: absolute;
left: 15px;
color: var(--navy);
opacity: 0.5;
z-index: 5;
}
.input-group-custom input,
.input-group-custom select {
width: 100%;
padding: 15px 15px 15px 45px !important;
border: 1px solid #e2e8f0;
border-radius: 12px;
font-size: 14px;
background-color: #f8fafc;
transition: all 0.3s ease;
cursor: pointer;
appearance: none;
}
.input-group-custom input:focus,
.input-group-custom select:focus {
background: #fff;
border-color: var(--gold);
box-shadow: 0 0 0 4px rgba(255, 174, 39, 0.1);
outline: none;
}
.btn-search-modern {
background: var(--gold);
color: var(--navy);
border: none;
padding: 15px 35px;
border-radius: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 10px;
white-space: nowrap;
}
.btn-search-modern:hover {
background: var(--navy);
color: #fff;
transform: translateY(-2px);
}
/* ===== SECTION TITRES ===== */
.section-title-wrapper {
text-align: center;
margin-bottom: 50px;
}
.section-title h3 {
font-size: 36px;
font-weight: 800;
color: var(--text-dark);
margin-bottom: 12px;
position: relative;
display: inline-block;
}
.section-title h3::after {
content: '';
position: absolute;
bottom: -12px;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 4px;
background: linear-gradient(90deg, var(--gold), var(--gold-dark));
border-radius: 2px;
}
.section-title p {
font-size: 16px;
color: var(--text-muted);
margin-top: 20px;
}
/* ===== COURSE AREA ===== */
.course-area {
padding: 80px 0;
background: #fff;
}
/* CARTE SESSION - HAUTEUR ÉGALE */
.single-event-item {
background: #fff;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 5px 20px rgba(0,0,0,0.05);
transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
height: 100%;
display: flex;
flex-direction: column;
border: 1px solid var(--border-light);
}
.single-event-item:hover {
transform: translateY(-8px);
box-shadow: 0 20px 40px rgba(31,57,113,0.15);
border-color: var(--gold);
}
/* IMAGE */
.single-event-image {
position: relative;
overflow: hidden;
height: 220px;
background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
display: flex;
align-items: center;
justify-content: center;
}
.single-event-image a {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.single-event-image img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
object-fit: contain;
transition: transform 0.4s ease;
}
.single-event-item:hover .single-event-image img {
transform: scale(1.05);
}
/* BADGE DATE */
.single-event-image span {
position: absolute;
top: 15px;
left: 15px;
background: linear-gradient(135deg, var(--gold), var(--gold-dark));
color: var(--navy);
padding: 8px 16px;
border-radius: 12px;
font-weight: 800;
font-size: 14px;
z-index: 3;
box-shadow: 0 4px 15px rgba(255,174,39,0.3);
transition: all 0.3s ease;
}
.single-event-item:hover .single-event-image span {
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(255,174,39,0.4);
}
/* CORPS DE LA CARTE */
.single-event-text {
padding: 20px;
flex: 1;
display: flex;
flex-direction: column;
}
.single-event-text h3 {
font-size: 18px;
font-weight: 700;
margin-bottom: 12px;
line-height: 1.4;
min-height: 50px;
}
.single-event-text h3 a {
color: var(--text-dark);
text-decoration: none;
transition: color 0.2s;
}
.single-event-text h3 a:hover {
color: var(--gold);
}
/* INFOS SESSION (DATE + LIEU) */
.single-item-comment-view {
display: flex;
gap: 15px;
margin-bottom: 15px;
flex-wrap: wrap;
}
.single-item-comment-view span {
font-size: 12px;
color: var(--text-muted);
display: flex;
align-items: center;
gap: 6px;
}
.single-item-comment-view span i {
color: var(--gold);
font-size: 14px;
}
/* DESCRIPTION */
.single-event-text > p {
font-size: 13px;
color: var(--text-muted);
line-height: 1.6;
margin-bottom: 20px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
/* BOUTON */
.button-default {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
background: linear-gradient(135deg, var(--navy), var(--navy-dark));
color: #fff;
border: none;
padding: 10px 24px;
border-radius: 30px;
font-weight: 600;
font-size: 13px;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
margin-top: auto;
align-self: flex-start;
}
.button-default:hover {
background: linear-gradient(135deg, var(--gold), var(--gold-dark));
color: var(--navy);
transform: translateX(4px);
}
/* MESSAGE AUCUNE SESSION */
.no-sessions-message {
text-align: center;
padding: 60px 40px;
background: var(--surface-white);
border-radius: var(--r-lg);
border: 1px solid var(--border-light);
box-shadow: var(--sh-sm);
max-width: 500px;
margin: 0 auto;
}
.no-sessions-icon {
font-size: 64px;
color: var(--gold);
margin-bottom: 20px;
}
.no-sessions-message h3 {
font-size: 24px;
font-weight: 700;
color: var(--text-dark);
margin-bottom: 12px;
}
.no-sessions-message p {
font-size: 15px;
color: var(--text-muted);
margin-bottom: 25px;
}
/* PAGINATION */
.pagination-wrapper {
margin-top: 40px;
text-align: center;
}
.pagination {
display: flex;
justify-content: center;
gap: 8px;
list-style: none;
padding: 0;
margin: 0;
}
.pagination .page-item {
list-style: none;
}
.pagination .page-link {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 12px;
background: #fff;
border: 1px solid var(--border-light);
color: var(--navy);
font-weight: 500;
text-decoration: none;
transition: all 0.3s ease;
}
.pagination .page-link:hover {
background: var(--gold);
border-color: var(--gold);
color: var(--navy);
}
.pagination .active .page-link {
background: linear-gradient(135deg, var(--navy), var(--navy-dark));
border-color: var(--navy);
color: #fff;
}
/* RESPONSIVE */
@media (max-width: 991px) {
.form-container-modern {
grid-template-columns: 1fr;
}
.breadcrumb-area {
padding: 60px 0 100px;
}
.breadcrumb-title h1 {
font-size: 32px;
}
.btn-search-modern {
justify-content: center;
}
}
@media (max-width: 768px) {
.section-title h3 {
font-size: 28px;
}
.single-event-image {
height: 180px;
}
.single-event-text h3 {
font-size: 16px;
min-height: auto;
}
.pagination .page-link {
width: 36px;
height: 36px;
font-size: 13px;
}
.single-item-comment-view {
gap: 10px;
}
}
/* ===== BADGE DATE CENTRÉ SOUS L'IMAGE ===== */
.event-date-badge {
position: relative;
display: flex;
align-items: center;
justify-content: center; /* Centrage horizontal */
background: linear-gradient(135deg, var(--gold), var(--gold-dark));
border-radius: 12px;
margin-top: 0;
margin-bottom: 15px;
padding: 8px 20px;
width: fit-content;
min-width: 80px; /* Largeur minimum pour un bon centrage */
box-shadow: 0 4px 15px rgba(255,174,39,0.2);
transition: all 0.3s ease;
z-index: 5;
gap: 10px;
/* Centrage horizontal */
margin-left: auto;
margin-right: auto;
}
.single-event-item:hover .event-date-badge {
transform: translateY(-3px);
box-shadow: 0 8px 20px rgba(255,174,39,0.3);
}
.event-date-badge .event-day {
font-size: 22px;
font-weight: 800;
color: var(--navy);
line-height: 1;
}
.event-date-badge .event-month {
font-size: 12px;
font-weight: 600;
color: var(--navy);
text-transform: uppercase;
letter-spacing: 1px;
}
/* Style pour les sessions passées */
.event-date-badge.past {
background: linear-gradient(135deg, #6c757d, #495057);
box-shadow: 0 4px 15px rgba(108,117,125,0.2);
}
.event-date-badge.past .event-day,
.event-date-badge.past .event-month {
color: #fff;
}
.single-event-item:hover .event-date-badge.past {
box-shadow: 0 8px 20px rgba(108,117,125,0.3);
}
/* Ajustement de l'image */
.single-event-image {
position: relative;
overflow: hidden;
height: 220px;
background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 0;
}
/* Corps de la carte */
.single-event-text {
padding: 0 20px 20px 20px;
flex: 1;
display: flex;
flex-direction: column;
}
.single-event-text h3 {
font-size: 18px;
font-weight: 700;
margin-bottom: 12px;
margin-top: 0;
line-height: 1.4;
text-align: left;
}
/* Responsive */
@media (max-width: 768px) {
.event-date-badge {
padding: 6px 16px;
min-width: 70px;
margin-bottom: 12px;
}
.event-date-badge .event-day {
font-size: 18px;
}
.event-date-badge .event-month {
font-size: 10px;
}
.single-event-text {
padding: 0 15px 15px 15px;
}
}
/* =====================================================
PROCHAINES SESSIONS - SCROLLABLE HORIZONTAL
===================================================== */
/* =====================================================
PROCHAINES SESSIONS - CARTES COMPACTES
===================================================== */
/* Container des sessions avec défilement horizontal */
.sessions-scroll-wrapper {
position: relative;
margin: 30px 0;
}
.sessions-scroll-container {
position: relative;
display: flex;
align-items: center;
gap: 10px;
}
.sessions-scroll-btn {
width: 40px;
height: 40px;
border-radius: 50%;
background: white;
border: 1px solid var(--border-light);
color: var(--navy);
font-size: 18px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
flex-shrink: 0;
z-index: 10;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.sessions-scroll-btn:hover {
background: var(--gold);
border-color: var(--gold);
color: var(--navy);
transform: scale(1.1);
}
.sessions-scroll-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
transform: none;
}
.sessions-rail {
flex: 1;
overflow-x: auto;
scroll-behavior: smooth;
scrollbar-width: none;
-ms-overflow-style: none;
cursor: grab;
border-radius: 20px;
}
.sessions-rail::-webkit-scrollbar {
display: none;
}
.sessions-rail:active {
cursor: grabbing;
}
.sessions-belt {
display: flex;
gap: 20px;
width: max-content;
padding: 10px 5px;
}
/* CARTE SESSION - TAILLE COMPACTE (comme sessions passées) */
.sessions-card {
width: 300px;
flex-shrink: 0;
}
/* Garder les styles existants de la carte */
.single-event-item {
background: #fff;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 5px 20px rgba(0,0,0,0.05);
transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
height: 100%;
display: flex;
flex-direction: column;
border: 1px solid var(--border-light);
}
.single-event-item:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(31,57,113,0.15);
}
/* Image plus petite */
.single-event-image {
height: 180px;
}
/* Badge date plus petit */
.event-date-badge {
padding: 6px 14px;
min-width: 65px;
margin-bottom: 10px;
}
.event-date-badge .event-day {
font-size: 18px;
}
.event-date-badge .event-month {
font-size: 10px;
}
/* Corps de la carte - padding réduit */
.single-event-text {
padding: 0 15px 15px 15px;
}
.single-event-text h3 {
font-size: 16px;
margin-bottom: 8px;
min-height: auto;
}
.single-item-comment-view {
margin-bottom: 10px;
gap: 10px;
}
.single-item-comment-view span {
font-size: 11px;
}
.single-event-text > p {
font-size: 12px;
margin-bottom: 12px;
-webkit-line-clamp: 2;
}
.button-default {
padding: 8px 18px;
font-size: 12px;
}
/* Indicateur de progression */
.sessions-scroll-indicator {
display: flex;
justify-content: center;
margin-top: 20px;
}
.sessions-scroll-bar {
width: 60px;
height: 3px;
background: #e9ecef;
border-radius: 3px;
position: relative;
overflow: hidden;
}
.sessions-scroll-bar::after {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 0%;
background: linear-gradient(90deg, var(--gold), var(--gold-dark));
border-radius: 3px;
transition: width 0.3s ease;
}
/* Responsive */
@media (max-width: 1200px) {
.sessions-card { width: 290px; }
}
@media (max-width: 992px) {
.sessions-card { width: 280px; }
}
@media (max-width: 768px) {
.sessions-scroll-btn { width: 36px; height: 36px; font-size: 16px; }
.sessions-card { width: 260px; }
.sessions-belt { gap: 12px; }
.single-event-image { height: 160px; }
.single-event-text h3 { font-size: 15px; }
}
@media (max-width: 576px) {
.sessions-scroll-btn { width: 32px; height: 32px; font-size: 14px; }
.sessions-card { width: 240px; }
.single-event-image { height: 140px; }
.single-event-text h3 { font-size: 14px; }
.event-date-badge .event-day { font-size: 16px; }
}
</style>
<!-- BREADCRUMB AREA -->
<div class="breadcrumb-area">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="breadcrumb-title">
<h1>Sessions de Formation</h1>
<ul class="breadcrumb-list">
<li><a href="{{ path('app_home') }}">Accueil</a></li>
<li><i class="zmdi zmdi-chevron-right"></i></li>
<li class="active">Sessions</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- SEARCH CATEGORY FLOATING -->
<!-- COURSE AREA - PROCHAINES SESSIONS -->
<!-- COURSE AREA - PROCHAINES SESSIONS -->
<div class="course-area">
<div class="container">
<!-- PROCHAINES SESSIONS - SCROLLABLE HORIZONTAL -->
<div class="sessions-scroll-wrapper">
<div class="section-title-wrapper">
<div class="section-title">
<h3>Prochaines Sessions</h3>
<p>Rejoignez nos prochaines sessions de formation</p>
</div>
</div>
{% if evenements is empty %}
<div class="no-sessions-message">
<div class="no-sessions-icon">
<i class="zmdi zmdi-calendar-close"></i>
</div>
<h3>Aucune session à venir</h3>
<p>De nouvelles sessions seront programmées prochainement. Revenez bientôt !</p>
</div>
{% else %}
<div class="sessions-scroll-container">
<!-- Bouton gauche -->
<button class="sessions-scroll-btn sessions-scroll-left" id="sessionsScrollLeft">
<i class="zmdi zmdi-chevron-left"></i>
</button>
<!-- Rail scrollable -->
<div class="sessions-rail" id="sessionsRail">
<div class="sessions-belt">
{% for evenement in evenements %}
<div class="sessions-card">
<div class="single-event-item">
<div class="single-event-image">
<a href="{{ path('app_details_session', {'slug': evenement.slug}) }}">
{% if evenement.image %}
<img src="{{ asset('uploads/evenement/' ~ evenement.image) }}" alt="{{ evenement.titre }}">
{% elseif evenement.formation %}
<img src="{{ asset('uploads/formation/' ~ evenement.formation.affiche) }}" alt="{{ evenement.titre }}">
{% else %}
<img src="{{ asset('assets2/img/placeholder.jpg') }}" alt="Image par défaut">
{% endif %}
</a>
</div>
<!-- BADGE DATE SOUS L'IMAGE -->
<div class="event-date-badge">
<span class="event-day">{{ evenement.starttime|date('d') }}</span>
<span class="event-month">{{ evenement.starttime|date('M') }}</span>
</div>
<div class="single-event-text">
<h3><a href="{{ path('app_details_session', {'slug': evenement.slug}) }}">{{ evenement.titre }}</a></h3>
<div class="single-item-comment-view">
<span><i class="zmdi zmdi-time"></i> {{ evenement.starttime|date('d/m H:i') }} - {{ evenement.endtime|date('d/m H:i') }}</span>
<span><i class="zmdi zmdi-pin"></i> {{ evenement.adresse }}</span>
</div>
<p>
{{ evenement.descriptionshort|striptags|slice(0, 200)|raw }}
{% if evenement.descriptionshort|striptags|length > 200 %}...{% endif %}
</p>
<a class="button-default" href="{{ path('app_details_session', {'slug': evenement.slug}) }}">
Voir les détails
<i class="zmdi zmdi-arrow-right"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Bouton droit -->
<button class="sessions-scroll-btn sessions-scroll-right" id="sessionsScrollRight">
<i class="zmdi zmdi-chevron-right"></i>
</button>
</div>
<!-- Indicateur de progression -->
<div class="sessions-scroll-indicator">
<div class="sessions-scroll-bar"></div>
</div>
{% endif %}
</div>
<!-- ANCIENNES SESSIONS -->
<!-- ANCIENNES SESSIONS -->
<div class="row mt-5">
<div class="col-md-12">
<div class="section-title-wrapper">
<div class="section-title">
<h3>Sessions Passées</h3>
<p>Consultez nos sessions déjà réalisées</p>
</div>
</div>
</div>
</div>
<div class="row">
{% if ancienevents is empty %}
<div class="col-md-12">
<div class="no-sessions-message">
<div class="no-sessions-icon">
<i class="zmdi zmdi-history"></i>
</div>
<h3>Aucune session passée</h3>
<p>Les sessions passées apparaîtront ici.</p>
</div>
</div>
{% else %}
{% for evenement in ancienevents %}
<div class="col-lg-4 col-md-6 col-12 mb-4 d-flex">
<div class="single-event-item w-100">
<div class="single-event-image">
<a href="{{ path('app_details_session', {'slug': evenement.slug}) }}">
{% if evenement.image %}
<img src="{{ asset('uploads/evenement/' ~ evenement.image) }}" alt="{{ evenement.titre }}">
{% elseif evenement.formation %}
<img src="{{ asset('uploads/formation/' ~ evenement.formation.affiche) }}" alt="{{ evenement.titre }}">
{% else %}
<img src="{{ asset('assets2/img/placeholder.jpg') }}" alt="Image par défaut">
{% endif %}
</a>
</div>
<!-- BADGE DATE POUR SESSIONS PASSÉES (STYLE GRIS) -->
<div class="event-date-badge past">
<span class="event-day">{{ evenement.starttime|date('d') }}</span>
<span class="event-month">{{ evenement.starttime|date('M') }}</span>
</div>
<div class="single-event-text">
<h3><a href="{{ path('app_details_session', {'slug': evenement.slug}) }}">{{ evenement.titre }}</a></h3>
<div class="single-item-comment-view">
<span><i class="zmdi zmdi-time"></i> {{ evenement.starttime|date('d/m H:i') }} - {{ evenement.endtime|date('d/m H:i') }}</span>
<span><i class="zmdi zmdi-pin"></i> {{ evenement.adresse }}</span>
</div>
<p>
{{ evenement.descriptionshort|striptags|slice(0, 200)|raw }}
{% if evenement.descriptionshort|striptags|length > 200 %}...{% endif %}
</p>
<a class="button-default" href="{{ path('app_details_session', {'slug': evenement.slug}) }}">
Voir les détails
<i class="zmdi zmdi-arrow-right"></i>
</a>
</div>
</div>
</div>
{% endfor %}
{% endif %}
</div>
<!-- PAGINATION POUR SESSIONS PASSÉES -->
{% if ancienevents is defined and ancienevents.pageCount > 1 %}
<div class="row">
<div class="col-12">
<div class="pagination-wrapper">
{{ knp_pagination_render(ancienevents, 'formation/custom_pagination.html.twig') }}
</div>
</div>
</div>
{% endif %}
</div>
</div>
<script>
/* ============================================
SESSIONS - SCROLL HORIZONTAL
============================================ */
(function() {
const container = document.getElementById('sessionsRail');
if (!container) return;
const leftBtn = document.getElementById('sessionsScrollLeft');
const rightBtn = document.getElementById('sessionsScrollRight');
const scrollBar = document.querySelector('.sessions-scroll-bar');
function getScrollAmount() {
const firstCard = document.querySelector('.sessions-card');
if (firstCard) {
const cardWidth = firstCard.offsetWidth;
const belt = document.querySelector('.sessions-belt');
const gap = belt ? parseInt(getComputedStyle(belt).gap) || 25 : 25;
return cardWidth + gap;
}
return 345;
}
function scrollLeft() {
const amount = getScrollAmount();
container.scrollBy({ left: -amount, behavior: 'smooth' });
setTimeout(updateScrollBar, 350);
setTimeout(checkButtons, 350);
}
function scrollRight() {
const amount = getScrollAmount();
container.scrollBy({ left: amount, behavior: 'smooth' });
setTimeout(updateScrollBar, 350);
setTimeout(checkButtons, 350);
}
function updateScrollBar() {
if (!scrollBar) return;
const maxScroll = container.scrollWidth - container.clientWidth;
const currentScroll = container.scrollLeft;
if (maxScroll > 0) {
const percentage = (currentScroll / maxScroll) * 100;
scrollBar.style.setProperty('--scroll-width', percentage + '%');
const afterElement = scrollBar.querySelector('::after');
if (afterElement) afterElement.style.width = percentage + '%';
}
}
function checkButtons() {
if (!leftBtn || !rightBtn) return;
const maxScroll = container.scrollWidth - container.clientWidth;
const currentScroll = container.scrollLeft;
leftBtn.disabled = currentScroll <= 10;
leftBtn.style.opacity = currentScroll <= 10 ? '0.4' : '1';
rightBtn.disabled = currentScroll >= maxScroll - 10;
rightBtn.style.opacity = currentScroll >= maxScroll - 10 ? '0.4' : '1';
}
if (leftBtn) leftBtn.addEventListener('click', scrollLeft);
if (rightBtn) rightBtn.addEventListener('click', scrollRight);
// Drag to scroll
let isDown = false;
let startX;
let scrollLeftPos;
container.addEventListener('mousedown', (e) => {
isDown = true;
container.style.cursor = 'grabbing';
startX = e.pageX - container.offsetLeft;
scrollLeftPos = container.scrollLeft;
});
container.addEventListener('mouseleave', () => {
isDown = false;
container.style.cursor = 'grab';
});
container.addEventListener('mouseup', () => {
isDown = false;
container.style.cursor = 'grab';
setTimeout(checkButtons, 100);
});
container.addEventListener('mousemove', (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - container.offsetLeft;
const walk = (x - startX) * 1.5;
container.scrollLeft = scrollLeftPos - walk;
updateScrollBar();
});
container.addEventListener('scroll', () => {
updateScrollBar();
checkButtons();
});
window.addEventListener('resize', () => {
setTimeout(() => {
updateScrollBar();
checkButtons();
}, 200);
});
setTimeout(() => {
updateScrollBar();
checkButtons();
}, 500);
})();
</script>
{% endblock %}