/
BingoX
/
Alternative
Обзор
Документация
Войти
/
BingoX
/
Alternative
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app/javascript/controllers/gallery_controller.js
38 строк
1 KB
Nikorexio
Первый коммит
15 май 2025, 18:36
15 май 2025, 18:36
190a17b
Код
Авторство
О чём код?
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = ["image", "thumbnail"] static values = { index: Number } connect() { console.log("Gallery controller connected"); this.indexValue = 0 this.showCurrentImage() } next(event) { console.log("Next button clicked"); if (this.indexValue < this.imageTargets.length - 1) { this.indexValue++ this.showCurrentImage() } } previous(event) { console.log("Previous button clicked"); if (this.indexValue > 0) { this.indexValue-- this.showCurrentImage() } } showCurrentImage() { console.log(`Showing image at index: ${this.indexValue}`); this.imageTargets.forEach((img, index) => { img.classList.toggle('hidden', index !== this.indexValue) }) this.thumbnailTargets.forEach((thumb, index) => { thumb.classList.toggle('border-blue-500', index === this.indexValue) }) } }