Spaces:
Running
Running
| <html lang="vi"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Case Study - {{ case.title }} | TTL1979</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| body { | |
| background-color: #000; | |
| color: #fff; | |
| overflow-x: hidden; | |
| } | |
| .parallax-bg { | |
| background-attachment: fixed; | |
| background-position: center; | |
| background-repeat: no-repeat; | |
| background-size: cover; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .glow-effect { | |
| position: absolute; | |
| width: 200px; | |
| height: 200px; | |
| border-radius: 50%; | |
| filter: blur(60px); | |
| opacity: 0.3; | |
| z-index: 0; | |
| } | |
| .glow-teal { | |
| background: #38b2ac; | |
| } | |
| .glow-blue { | |
| background: #3b82f6; | |
| } | |
| .glow-purple { | |
| background: #8b5cf6; | |
| } | |
| .case-comparison { | |
| position: relative; | |
| width: 100%; | |
| height: 600px; | |
| overflow: hidden; | |
| border-radius: 16px; | |
| box-shadow: 0 10px 30px rgba(0,0,0,0.5); | |
| } | |
| .before-image, .after-image { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| } | |
| .before-image { | |
| clip-path: polygon(0 0, 50% 0, 50% 100%, 0% 100%); | |
| } | |
| .after-image { | |
| clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%); | |
| } | |
| .comparison-slider { | |
| position: absolute; | |
| top: 0; | |
| bottom: 0; | |
| width: 4px; | |
| background: white; | |
| left: 50%; | |
| transform: translateX(-50%); | |
| cursor: ew-resize; | |
| z-index: 10; | |
| } | |
| .comparison-slider::before { | |
| content: ''; | |
| position: absolute; | |
| width: 50px; | |
| height: 50px; | |
| border-radius: 50%; | |
| background: white; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| } | |
| .comparison-slider::after { | |
| content: '\f337'; | |
| font-family: 'Font Awesome 6 Free'; | |
| font-weight: 900; | |
| position: absolute; | |
| color: #000; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| font-size: 20px; | |
| } | |
| .treatment-timeline { | |
| position: relative; | |
| padding-left: 30px; | |
| } | |
| .treatment-timeline::before { | |
| content: ''; | |
| position: absolute; | |
| left: 0; | |
| top: 0; | |
| bottom: 0; | |
| width: 4px; | |
| background: linear-gradient(to bottom, #3b82f6, #8b5cf6); | |
| } | |
| .timeline-item { | |
| position: relative; | |
| padding-bottom: 30px; | |
| } | |
| .timeline-item::before { | |
| content: ''; | |
| position: absolute; | |
| left: -33px; | |
| top: 5px; | |
| width: 12px; | |
| height: 12px; | |
| border-radius: 50%; | |
| background: #3b82f6; | |
| border: 2px solid white; | |
| } | |
| .gallery-slider { | |
| scroll-snap-type: x mandatory; | |
| scroll-behavior: smooth; | |
| } | |
| .gallery-slide { | |
| scroll-snap-align: start; | |
| flex: 0 0 100%; | |
| } | |
| @media (max-width: 768px) { | |
| .parallax-bg { | |
| background-attachment: scroll; | |
| } | |
| .case-comparison { | |
| height: 400px; | |
| } | |
| .gallery-slide { | |
| flex: 0 0 100%; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Floating Glow Effects --> | |
| <div class="glow-effect glow-teal" style="top: 10%; left: 10%;"></div> | |
| <div class="glow-effect glow-blue" style="top: 60%; right: 5%;"></div> | |
| <div class="glow-effect glow-purple" style="bottom: 10%; left: 20%;"></div> | |
| <!-- Header --> | |
| <header class="py-6 px-4 fixed w-full z-50 bg-black bg-opacity-80 backdrop-filter backdrop-blur-sm"> | |
| <div class="container mx-auto flex justify-between items-center"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-tooth text-3xl text-teal-400 mr-3"></i> | |
| <h1 class="text-2xl font-bold bg-gradient-to-r from-teal-400 to-blue-500 bg-clip-text text-transparent">TTL1979</h1> | |
| </div> | |
| <button id="menu-toggle" class="md:hidden text-white"> | |
| <i class="fas fa-bars text-2xl"></i> | |
| </button> | |
| <nav id="main-nav" class="hidden md:flex space-x-8"> | |
| <a href="/" class="nav-link text-white hover:text-teal-400 transition">Home</a> | |
| <a href="/thuvien" class="nav-link text-white hover:text-teal-400 transition">Thư viện</a> | |
| <a href="/dichvu" class="nav-link text-white hover:text-teal-400 transition">Dịch vụ</a> | |
| <a href="/lienhe" class="nav-link text-white hover:text-teal-400 transition">Liên hệ</a> | |
| </nav> | |
| </div> | |
| </header> | |
| <!-- Mobile Menu --> | |
| <div id="mobile-menu" class="fixed inset-0 bg-black bg-opacity-90 z-40 hidden flex-col items-center justify-center space-y-8"> | |
| <button id="close-menu" class="absolute top-6 right-6 text-white text-2xl"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| <a href="/" class="text-white text-2xl hover:text-teal-400 transition">Home</a> | |
| <a href="/thuvien" class="text-white text-2xl hover:text-teal-400 transition">Thư viện</a> | |
| <a href="/dichvu" class="text-white text-2xl hover:text-teal-400 transition">Dịch vụ</a> | |
| <a href="/lienhe" class="text-white text-2xl hover:text-teal-400 transition">Liên hệ</a> | |
| </div> | |
| <!-- Case Study Hero --> | |
| <section class="pt-32 pb-20 px-4"> | |
| <div class="container mx-auto"> | |
| {% if case %} | |
| <div class="flex flex-col md:flex-row items-center mb-12"> | |
| <div class="md:w-1/2 mb-8 md:mb-0 md:pr-8"> | |
| <span class="inline-block bg-gradient-to-r from-teal-500 to-blue-600 text-white px-4 py-1 rounded-full text-sm font-semibold mb-4">Case #{{ case.case_id }}</span> | |
| <h1 class="text-4xl md:text-5xl font-bold mb-6 bg-gradient-to-r from-teal-400 to-blue-500 bg-clip-text text-transparent">{{ case.title }}</h1> | |
| <p class="text-xl text-gray-300 mb-6">{{ case.initial_condition }}</p> | |
| <div class="flex items-center"> | |
| <div class="w-16 h-16 rounded-full overflow-hidden border-2 border-teal-500 mr-4"> | |
| <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="Patient" class="w-full h-full object-cover"> | |
| </div> | |
| <div> | |
| <h4 class="font-bold">{{ case.patient_name }}</h4> | |
| <p class="text-teal-400">Khách hàng hài lòng</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="md:w-1/2"> | |
| <div class="bg-gradient-to-br from-teal-500 to-blue-600 p-1 rounded-2xl"> | |
| <div class="case-comparison bg-black rounded-xl overflow-hidden"> | |
| <img src="{{ case.before_image }}" alt="Before treatment" class="before-image"> | |
| <img src="{{ case.after_image }}" alt="After treatment" class="after-image"> | |
| <div class="comparison-slider"></div> | |
| <div class="absolute top-4 left-4 bg-black bg-opacity-70 text-white px-3 py-1 rounded-full text-sm"> | |
| <i class="fas fa-arrow-left mr-1"></i> Trước | |
| </div> | |
| <div class="absolute top-4 right-4 bg-black bg-opacity-70 text-white px-3 py-1 rounded-full text-sm"> | |
| Sau <i class="fas fa-arrow-right ml-1"></i> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex flex-wrap justify-center gap-4 mb-12"> | |
| <span class="bg-gray-800 text-teal-400 px-4 py-2 rounded-full font-medium">{{ case.treatment_method }}</span> | |
| <span class="bg-gray-800 text-blue-400 px-4 py-2 rounded-full font-medium">Thẩm mỹ</span> | |
| <span class="bg-gray-800 text-purple-400 px-4 py-2 rounded-full font-medium">Không đau</span> | |
| <span class="bg-gray-800 text-pink-400 px-4 py-2 rounded-full font-medium">{{ case.treatment_duration }}</span> | |
| </div> | |
| {% else %} | |
| <div class="text-center"> | |
| <h1 class="text-4xl font-bold mb-6 text-gray-300">Chưa có dữ liệu ca điều trị</h1> | |
| <p class="text-xl text-gray-400">Vui lòng thêm dữ liệu vào dataset để hiển thị ca điều trị.</p> | |
| </div> | |
| {% endif %} | |
| </div> | |
| </section> | |
| <!-- Case Details --> | |
| <section class="py-16 px-4 bg-gray-900 bg-opacity-50"> | |
| <div class="container mx-auto"> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-12"> | |
| <div class="lg:col-span-2"> | |
| <h2 class="text-3xl font-bold mb-8 bg-gradient-to-r from-teal-400 to-blue-500 bg-clip-text text-transparent">Chi tiết ca điều trị</h2> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-6 mb-8 backdrop-filter backdrop-blur-sm"> | |
| <h3 class="text-xl font-semibold mb-4 text-teal-400 flex items-center"> | |
| <i class="fas fa-clipboard-list mr-2"></i> Tình trạng ban đầu | |
| </h3> | |
| <p class="text-gray-300 mb-4">{{ case.initial_condition }}</p> | |
| <ul class="list-disc pl-6 text-gray-300 space-y-2"> | |
| {% for detail in case.initial_details.split(';') %} | |
| <li>{{ detail.strip() }}</li> | |
| {% endfor %} | |
| </ul> | |
| </div> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-6 mb-8 backdrop-filter backdrop-blur-sm"> | |
| <h3 class="text-xl font-semibold mb-4 text-blue-400 flex items-center"> | |
| <i class="fas fa-procedures mr-2"></i> Phương pháp điều trị | |
| </h3> | |
| <p class="text-gray-300 mb-4">{{ case.treatment_method }} với các ưu điểm:</p> | |
| <ul class="list-disc pl-6 text-gray-300 space-y-2"> | |
| {% for benefit in case.treatment_benefits.split(';') %} | |
| <li>{{ benefit.strip() }}</li> | |
| {% endfor %} | |
| </ul> | |
| </div> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-6 backdrop-filter backdrop-blur-sm"> | |
| <h3 class="text-xl font-semibold mb-4 text-purple-400 flex items-center"> | |
| <i class="fas fa-smile-beam mr-2"></i> Kết quả đạt được | |
| </h3> | |
| <p class="text-gray-300 mb-4">Sau khi hoàn thành điều trị, bệnh nhân đạt được:</p> | |
| <ul class="list-disc pl-6 text-gray-300 space-y-2"> | |
| {% for result in case.results.split(';') %} | |
| <li>{{ result.strip() }}</li> | |
| {% endfor %} | |
| </ul> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="sticky top-24"> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-6 mb-6 backdrop-filter backdrop-blur-sm"> | |
| <h3 class="text-xl font-semibold mb-4 border-b border-gray-700 pb-2">Thông tin ca điều trị</h3> | |
| <div class="space-y-4"> | |
| <div> | |
| <p class="text-gray-400 text-sm">Bệnh nhân</p> | |
| <p class="font-medium">{{ case.patient_name }}</p> | |
| </div> | |
| <div> | |
| <p class="text-gray-400 text-sm">Tuổi</p> | |
| <p class="font-medium">{{ case.patient_age }}</p> | |
| </div> | |
| <div> | |
| <p class="text-gray-400 text-sm">Phương pháp</p> | |
| <p class="font-medium text-teal-400">{{ case.treatment_method }}</p> | |
| </div> | |
| <div> | |
| <p class="text-gray-400 text-sm">Số răng điều trị</p> | |
| <p class="font-medium">{{ case.num_teeth }}</p> | |
| </div> | |
| <div> | |
| <p class="text-gray-400 text-sm">Thời gian</p> | |
| <p class="font-medium">{{ case.treatment_duration }}</p> | |
| </div> | |
| <div> | |
| <p class="text-gray-400 text-sm">Độ bền</p> | |
| <p class="font-medium">{{ case.durability }}</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-6 backdrop-filter backdrop-blur-sm"> | |
| <h3 class="text-xl font-semibold mb-4 border-b border-gray-700 pb-2">Bác sĩ điều trị</h3> | |
| <div class="flex items-center mb-4"> | |
| <div class="w-16 h-16 rounded-full overflow-hidden border-2 border-blue-500 mr-4"> | |
| <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="Doctor" class="w-full h-full object-cover"> | |
| </div> | |
| <div> | |
| <h4 class="font-bold">{{ case.doctor_name }}</h4> | |
| <p class="text-blue-400">Chuyên gia thẩm mỹ nha khoa</p> | |
| </div> | |
| </div> | |
| <p class="text-gray-300 text-sm">{{ case.doctor_experience }}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Image Gallery Slider --> | |
| <section class="py-16 px-4 bg-black"> | |
| <div class="container mx-auto"> | |
| <h2 class="text-3xl font-bold mb-12 text-center bg-gradient-to-r from-teal-400 to-blue-500 bg-clip-text text-transparent">Hình ảnh điều trị</h2> | |
| <div class="relative"> | |
| <div class="gallery-slider flex overflow-x-auto snap-x snap-mandatory scroll-smooth rounded-xl shadow-2xl" id="gallery-slider"> | |
| {% for image in case.gallery_images.split(',') %} | |
| <div class="gallery-slide flex-shrink-0 w-full"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div class="bg-gray-900 rounded-xl overflow-hidden"> | |
| <img src="{{ image.strip() }}" alt="Before treatment" class="w-full h-96 object-cover"> | |
| <div class="p-4 bg-gray-800"> | |
| <h4 class="font-semibold text-teal-400">Trước điều trị</h4> | |
| <p class="text-gray-400 text-sm">{{ ['Nhìn thẳng', 'Góc nghiêng', 'Cận cảnh'][loop.index0] }}</p> | |
| </div> | |
| </div> | |
| <div class="bg-gray-900 rounded-xl overflow-hidden"> | |
| <img src="{{ image.strip() }}" alt="After treatment" class="w-full h-96 object-cover"> | |
| <div class="p-4 bg-gray-800"> | |
| <h4 class="font-semibold text-blue-400">Sau điều trị</h4> | |
| <p class="text-gray-400 text-sm">{{ ['Nhìn thẳng', 'Góc nghiêng', 'Cận cảnh'][loop.index0] }}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| {% endfor %} | |
| </div> | |
| <div class="flex justify-center mt-6 space-x-2"> | |
| {% for image in case.gallery_images.split(',') %} | |
| <button class="gallery-dot w-3 h-3 rounded-full bg-gray-700 hover:bg-gray-500 transition" data-slide="{{ loop.index0 }}"></button> | |
| {% endfor %} | |
| </div> | |
| <button class="absolute left-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-70 text-white p-3 rounded-full hover:bg-opacity-90 transition" id="prev-slide"> | |
| <i class="fas fa-chevron-left"></i> | |
| </button> | |
| <button class="absolute right-4 top-1/2 transform -translate-y-1/2 bg-black bg-opacity-70 text-white p-3 rounded-full hover:bg-opacity-90 transition" id="next-slide"> | |
| <i class="fas fa-chevron-right"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Patient Testimonial --> | |
| <section class="py-16 px-4 bg-gradient-to-br from-gray-900 to-gray-800"> | |
| <div class="container mx-auto max-w-4xl"> | |
| <div class="bg-gray-800 bg-opacity-70 rounded-xl p-8 md:p-12 backdrop-filter backdrop-blur-sm"> | |
| <div class="flex flex-col md:flex-row items-center mb-8"> | |
| <div class="md:w-1/4 mb-6 md:mb-0 flex justify-center"> | |
| <div class="w-32 h-32 rounded-full overflow-hidden border-4 border-teal-500"> | |
| <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="Patient" class="w-full h-full object-cover"> | |
| </div> | |
| </div> | |
| <div class="md:w-3/4 md:pl-8 text-center md:text-left"> | |
| <h3 class="text-2xl font-bold mb-2">{{ case.patient_name }}</h3> | |
| <p class="text-teal-400 mb-4">Khách hàng hài lòng</p> | |
| <div class="flex justify-center md:justify-start space-x-1 text-yellow-400"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="text-center"> | |
| <blockquote class="text-xl italic mb-8"> | |
| "{{ case.patient_testimonial }}" | |
| </blockquote> | |
| <div class="flex justify-center space-x-4"> | |
| <button class="bg-teal-600 hover:bg-teal-700 text-white px-6 py-3 rounded-full font-medium transition flex items-center"> | |
| <i class="fas fa-calendar-check mr-2"></i> Đặt lịch ngay | |
| </button> | |
| <button class="bg-transparent border-2 border-teal-500 text-teal-400 hover:bg-teal-900 hover:bg-opacity-30 px-6 py-3 rounded-full font-medium transition flex items-center"> | |
| <i class="fas fa-phone-alt mr-2"></i> 0901.234.567 | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Footer --> | |
| <footer class="bg-black py-12 px-4"> | |
| <div class="container mx-auto"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-8"> | |
| <div> | |
| <div class="flex items-center mb-4"> | |
| <i class="fas fa-tooth text-3xl text-teal-400 mr-3"></i> | |
| <h3 class="text-2xl font-bold bg-gradient-to-r from-teal-400 to-blue-500 bg-clip-text text-transparent">TTL1979</h3> | |
| </div> | |
| <p class="text-gray-400 mb-4">Nha khoa thẩm mỹ hàng đầu Việt Nam với hơn 15 năm kinh nghiệm.</p> | |
| <div class="flex space-x-4"> | |
| <a href="#" class="text-gray-400 hover:text-teal-400 transition"> | |
| <i class="fab fa-facebook-f"></i> | |
| </a> | |
| <a href="#" class="text-gray-400 hover:text-teal-400 transition"> | |
| <i class="fab fa-instagram"></i> | |
| </a> | |
| <a href="#" class="text-gray-400 hover:text-teal-400 transition"> | |
| <i class="fab fa-youtube"></i> | |
| </a> | |
| <a href="#" class="text-gray-400 hover:text-teal-400 transition"> | |
| <i class="fab fa-tiktok"></i> | |
| </a> | |
| </div> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4 text-white border-b border-gray-800 pb-2">Dịch vụ</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-teal-400 transition">Dán sứ Veneer</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-teal-400 transition">Bọc răng sứ</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-teal-400 transition">Niềng răng</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-teal-400 transition">Cấy ghép Implant</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-teal-400 transition">Tẩy trắng răng</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4 text-white border-b border-gray-800 pb-2">Liên hệ</h4> | |
| <ul class="space-y-3 text-gray-400"> | |
| <li class="flex items-start"> | |
| <i class="fas fa-map-marker-alt mt-1 mr-3 text-teal-400"></i> | |
| <span>123 Nguyễn Văn Linh, Quận 7, TP.HCM</span> | |
| </li> | |
| <li class="flex items-center"> | |
| <i class="fas fa-phone-alt mr-3 text-teal-400"></i> | |
| <span>0901.234.567</span> | |
| </li> | |
| <li class="flex items-center"> | |
| <i class="fas fa-envelope mr-3 text-teal-400"></i> | |
| <span>info@ttl1979.com</span> | |
| </li> | |
| <li class="flex items-center"> | |
| <i class="fas fa-clock mr-3 text-teal-400"></i> | |
| <span>8:00 - 20:00 (T2 - CN)</span> | |
| </li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4 text-white border-b border-gray-800 pb-2">Đăng ký nhận tin</h4> | |
| <p class="text-gray-400 mb-4">Nhận thông tin ưu đãi và kiến thức nha khoa hữu ích.</p> | |
| <form class="flex"> | |
| <input type="email" placeholder="Email của bạn" class="bg-gray-900 text-white px-4 py-2 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-teal-500 w-full"> | |
| <button type="submit" class="bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-r-lg"> | |
| <i class="fas fa-paper-plane"></i> | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-800 mt-12 pt-8 flex flex-col md:flex-row justify-between items-center"> | |
| <p class="text-gray-500 text-sm mb-4 md:mb-0">© 2023 TTL1979. All rights reserved.</p> | |
| <div class="flex space-x-6"> | |
| <a href="#" class="text-gray-500 hover:text-teal-400 text-sm transition">Chính sách bảo mật</a> | |
| <a href="#" class="text-gray-500 hover:text-teal-400 text-sm transition">Điều khoản sử dụng</a> | |
| <a href="#" class="text-gray-500 hover:text-teal-400 text-sm transition">Sitemap</a> | |
| </div> | |
| </div> | |
| </div> | |
| </footer> | |
| <script> | |
| // Mobile menu toggle | |
| const menuToggle = document.getElementById('menu-toggle'); | |
| const closeMenu = document.getElementById('close-menu'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| menuToggle.addEventListener('click', () => { | |
| mobileMenu.classList.remove('hidden'); | |
| mobileMenu.classList.add('flex'); | |
| }); | |
| closeMenu.addEventListener('click', () => { | |
| mobileMenu.classList.add('hidden'); | |
| mobileMenu.classList.remove('flex'); | |
| }); | |
| // Before/After slider | |
| const slider = document.querySelector('.comparison-slider'); | |
| const beforeImage = document.querySelector('.before-image'); | |
| let isDragging = false; | |
| slider.addEventListener('mousedown', (e) => { | |
| isDragging = true; | |
| document.addEventListener('mousemove', onDrag); | |
| document.addEventListener('mouseup', () => { | |
| isDragging = false; | |
| document.removeEventListener('mousemove', onDrag); | |
| }); | |
| }); | |
| slider.addEventListener('touchstart', (e) => { | |
| isDragging = true; | |
| document.addEventListener('touchmove', onDrag); | |
| document.addEventListener('touchend', () => { | |
| isDragging = false; | |
| document.removeEventListener('touchmove', onDrag); | |
| }); | |
| }); | |
| function onDrag(e) { | |
| if (!isDragging) return; | |
| let x; | |
| if (e.type === 'mousemove') { | |
| x = e.clientX; | |
| } else if (e.type === 'touchmove') { | |
| x = e.touches[0].clientX; | |
| } | |
| const containerRect = slider.parentNode.getBoundingClientRect(); | |
| let percentage = ((x - containerRect.left) / containerRect.width) * 100; | |
| // Limit between 5% and 95% | |
| percentage = Math.max(5, Math.min(95, percentage)); | |
| beforeImage.style.clipPath = `polygon(0 0, ${percentage}% 0, ${percentage}% 100%, 0% 100%)`; | |
| slider.style.left = `${percentage}%`; | |
| } | |
| // Image gallery slider | |
| const gallerySlider = document.getElementById('gallery-slider'); | |
| const prevSlide = document.getElementById('prev-slide'); | |
| const nextSlide = document.getElementById('next-slide'); | |
| const dots = document.querySelectorAll('.gallery-dot'); | |
| let currentSlide = 0; | |
| function goToSlide(index) { | |
| currentSlide = index; | |
| gallerySlider.scrollTo({ | |
| left: gallerySlider.offsetWidth * index, | |
| behavior: 'smooth' | |
| }); | |
| updateDots(); | |
| } | |
| function updateDots() { | |
| dots.forEach((dot, index) => { | |
| if (index === currentSlide) { | |
| dot.classList.add('bg-teal-500'); | |
| dot.classList.remove('bg-gray-700'); | |
| } else { | |
| dot.classList.add('bg-gray-700'); | |
| dot.classList.remove('bg-teal-500'); | |
| } | |
| }); | |
| } | |
| prevSlide.addEventListener('click', () => { | |
| currentSlide = (currentSlide - 1 + dots.length) % dots.length; | |
| goToSlide(currentSlide); | |
| }); | |
| nextSlide.addEventListener('click', () => { | |
| currentSlide = (currentSlide + 1) % dots.length; | |
| goToSlide(currentSlide); | |
| }); | |
| dots.forEach((dot, index) => { | |
| dot.addEventListener('click', () => { | |
| goToSlide(index); | |
| }); | |
| }); | |
| // Initialize | |
| updateDots(); | |
| </script> | |
| </body> | |
| </html> |