Ekaropolus 0fd26e483f
All checks were successful
continuous-integration/drone/push Build is passing
Genesis commit for the new page
2025-04-22 13:14:25 -06:00

102 lines
2.8 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
if (!document.querySelector('.slide')) return;
window.addEventListener('load', function() {
/* 2.5 Reviews slider */
$(function (){
if ($('.home-page').length > 0){
var slideDuration = 0.3;
var slides = document.querySelectorAll(".slide");
var prevButton = document.querySelector("#prevButton");
var nextButton = document.querySelector("#nextButton");
var numSlides = slides.length;
for (var i = 0; i < numSlides; i++) {
TweenLite.set(slides[i], {
backgroundColor: Math.random() * 0xffffff,
xPercent: i * 100
});
}
var wrap = wrapPartial(-100, (numSlides - 1) * 100);
var animation = TweenMax.to(slides, 1, {
xPercent: "-=" + (numSlides * 100),
ease: Linear.easeNone,
paused: true,
repeat: -1,
modifiers: {
xPercent: wrap
}
});
var proxy = document.createElement("div");
TweenLite.set(proxy, { x: "+=0" });
var slideAnimation = TweenLite.to({}, 0.1, {});
var slideWidth = 0;
var wrapWidth = 0;
resize();
window.addEventListener("resize", resize);
prevButton.addEventListener("click", function() {
animateSlides(-1);
});
nextButton.addEventListener("click", function() {
animateSlides(1);
});
function animateSlides(direction) {
slideAnimation.kill();
var x = snapX(gsap.getProperty(proxy,'x') + direction * slideWidth);
slideAnimation = gsap.to(proxy, {duration: slideDuration, x: x,onUpdate: updateProgress});
}
function updateProgress() {
animation.progress(gsap.getProperty(proxy,'x') / wrapWidth);
}
function snapX(x) {
return Math.round(x / slideWidth) * slideWidth;
}
function resize() {
var norm = (gsap.getProperty(proxy,'x') / wrapWidth) || 0;
slideWidth = slides[0].offsetWidth;
wrapWidth = slideWidth * numSlides;
TweenLite.set(proxy, {
x: norm * wrapWidth
});
animateSlides(0);
slideAnimation.progress(1);
}
function wrapPartial(min, max) {
var r = max - min;
return function(value) {
var v = value - min;
return ((r + v % r) % r) + min;
}
}
}
$('.content__form-input input').on('change blur',function (){
let value = $(this).val();
if (value.length > 0){
$(this).addClass('valid');
} else {
$(this).removeClass('valid');
}
});
});
/* 2.6 Form */
});
});