try-me-today / script.js
spwotton's picture
card # 1 is this image
364693f verified
// Smooth scroll for navigation links
document.addEventListener('DOMContentLoaded', function() {
// Product filter functionality
const filterButtons = document.querySelectorAll('.filter-btn');
const productCards = document.querySelectorAll('.product-card');
filterButtons.forEach(button => {
button.addEventListener('click', () => {
const filter = button.dataset.filter;
// Update active button
filterButtons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
// Filter products
productCards.forEach(card => {
if (filter === 'all' || card.dataset.category === filter) {
card.classList.remove('hidden');
card.style.animation = 'fadeInUp 0.5s ease-out';
} else {
card.classList.add('hidden');
}
});
});
});
// Order button functionality
const orderButtons = document.querySelectorAll('.btn-order');
orderButtons.forEach(button => {
button.addEventListener('click', function() {
const productName = this.closest('.product-card').querySelector('.product-name').textContent;
const message = `¡Hola! Me gustaría ordenar: ${productName}`;
const whatsappUrl = `https://wa.me/584141234567?text=${encodeURIComponent(message)}`;
window.open(whatsappUrl, '_blank');
});
});
// Intersection Observer for animations
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');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe elements for animation
const animateElements = document.querySelectorAll('.product-card, .testimonial-card, .story-content');
animateElements.forEach(el => {
observer.observe(el);
});
// Parallax effect for hero section
const heroSection = document.querySelector('.hero');
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallax = heroSection.querySelector('.hero-content');
if (parallax) {
const speed = 0.5;
parallax.style.transform = `translateY(${scrolled * speed}px)`;
}
});
// Add loading animation for images
const images = document.querySelectorAll('img');
images.forEach(img => {
img.addEventListener('load', function() {
this.style.opacity = '1';
});
img.style.opacity = '0';
img.style.transition = 'opacity 0.3s ease';
});
// WhatsApp quick action button (floating)
const whatsappButton = document.createElement('div');
whatsappButton.innerHTML = `
<a href="https://wa.me/584141234567" target="_blank" class="whatsapp-float">
<svg width="24" height="24" viewBox="0 0 24 24" fill="white">
<path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.149-.67.149-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.521.151-.172.2-.296.3-.495.099-.198.05-.372-.025-.521-.075-.148-.669-1.611-.916-2.206-.242-.579-.487-.501-.669-.51l-.57-.01c-.198 0-.52.074-.792.372s-1.04 1.016-1.04 2.479 1.065 2.876 1.213 3.074c.149.198 2.095 3.2 5.076 4.487.709.306 1.263.489 1.694.626.712.226 1.36.194 1.872.118.571-.085 1.758-.719 2.006-1.413.248-.695.248-1.29.173-1.414-.074-.123-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/>
</svg>
</a>
`;
whatsappButton.style.cssText = `
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
`;
document.body.appendChild(whatsappButton);
// Add WhatsApp button styles
const whatsappStyle = document.createElement('style');
whatsappStyle.textContent = `
.whatsapp-float {
background-color: #25D366;
color: white;
width: 60px;
height: 60px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
text-decoration: none;
transition: all 0.3s ease;
}
.whatsapp-float:hover {
transform: scale(1.1);
box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}
`;
document.head.appendChild(whatsappStyle);
// Instagram feed mockup interaction
const instagramPosts = document.querySelectorAll('.instagram-post');
instagramPosts.forEach((post, index) => {
post.addEventListener('click', () => {
window.open('https://instagram.com/tryme_vnzl', '_blank');
});
});
// Quick view functionality
const quickViews = document.querySelectorAll('.quick-view');
quickViews.forEach(view => {
view.addEventListener('click', (e) => {
e.stopPropagation();
const card = view.closest('.product-card');
const productName = card.querySelector('.product-name').textContent;
const productDescription = card.querySelector('.product-description').textContent;
const productPrice = card.querySelector('.product-price').textContent;
const productImage = card.querySelector('.product-image img').src;
// Create modal
const modal = document.createElement('div');
modal.className = 'product-modal';
modal.innerHTML = `
<div class="modal-content">
<span class="modal-close">&times;</span>
<img src="${productImage}" alt="${productName}">
<h3>${productName}</h3>
<p>${productDescription}</p>
<div class="modal-price">${productPrice}</div>
<button class="btn-order">Pedir Ahora</button>
</div>
`;
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
`;
document.body.appendChild(modal);
// Close modal
modal.querySelector('.modal-close').addEventListener('click', () => {
modal.remove();
});
modal.addEventListener('click', (e) => {
if (e.target === modal) {
modal.remove();
}
});
// Order button in modal
modal.querySelector('.btn-order').addEventListener('click', () => {
const message = `¡Hola! Me gustaría ordenar: ${productName}`;
const whatsappUrl = `https://wa.me/584141234567?text=${encodeURIComponent(message)}`;
window.open(whatsappUrl, '_blank');
modal.remove();
});
});
});
});