Tem dúvidas ou deseja entrar em contato conosco?
Preencha o formulário abaixo com sua mensagem. Em breve responderemos
jQuery(document).ready(function($) { const container = $('.tt-container'); if (!container.length) return; const currentId = container.data('current-id'); const isRandom = $('.tt-btn-random').length > 0; // Navegação AJAX $('.tt-btn[data-direction]').click(function(e) { e.preventDefault(); const btn = $(this); const direction = btn.data('direction'); container.addClass('tt-loading'); $.post(TT_VARS.ajax_url, { action: 'tt_navigate', nonce: TT_VARS.nonce, current_id: currentId, direction: direction }).done(function(response) { if (response.success) { window.location.href = response.data.url; } else { alert('Erro ao carregar tirinha.'); container.removeClass('tt-loading'); } }); }); // Modal fullscreen $('.tt-image').click(function() { $(this).toggleClass('fullscreen'); }); // Teclado $(document).keydown(function(e) { if (e.key === 'ArrowLeft') $('.tt-btn-prev').click(); if (e.key === 'ArrowRight') $('.tt-btn-next').click(); if (e.key === ' ' && isRandom) { e.preventDefault(); $('.tt-btn-random').click(); } }); // Swipe mobile let touchStartX = 0; let touchEndX = 0; container.on('touchstart', function(e) { touchStartX = e.originalEvent.touches[0].screenX; }); container.on('touchend', function(e) { touchEndX = e.originalEvent.changedTouches[0].screenX; handleSwipe(); }); function handleSwipe() { const swipeThreshold = 50; const diff = touchStartX - touchEndX; if (Math.abs(diff) > swipeThreshold) { if (diff > 0) { $('.tt-btn-next').click(); // Swipe left = próxima } else { $('.tt-btn-prev').click(); // Swipe right = anterior } } } }); // Handler AJAX add_action('wp_ajax_tt_navigate', [$this, 'api_navigate']); add_action('wp_ajax_nopriv_tt_navigate', [$this, 'api_navigate']);
Tem dúvidas ou deseja entrar em contato conosco?
Preencha o formulário abaixo com sua mensagem. Em breve responderemos