File: /home/ser65kty/gamium.serversmw.com/resources/js/scripts.js
//LOADER
$(window).on('load', function(){
setTimeout(removeLoader, 1000);
});
function removeLoader(){
$( ".loader-wrapper" ).fadeOut(500, function() {
$( ".loader-wrapper" ).remove();
});
}
//Add menu active class
$(function(){
var current = location.pathname;
//remove lang prefix
if(current.startsWith("/es")){
current = current.slice(3);
}
$('#stickynavbar li a').each(function(){
var $this = $(this);
// if the current path is like this link, make it active
if(($this.attr('href').indexOf(current) !== -1) && (current != '/')){
$this.addClass('active');
}
})
})
//Minify navbar
$(document).ready(function () {
$("nav").find("li").on("click", "a", function () {
$('.navbar-collapse').collapse('hide');
});
});
// adds ios class to html tag
jQuery(document).ready(function($){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
$('body').addClass('ios');
}
});
//Scroll to top
const btnScrollToTop = document.querySelector(".btnScrollToTop");
window.addEventListener('scroll', e => {
btnScrollToTop.style.display = window.scrollY > 20 ? 'block' : 'none';
});
//GSAP REGISTER
gsap.registerPlugin(ScrollTrigger, ScrollSmoother);
//GSAP SMOOTHER
if($(window).width() > 1023){
let smoother = ScrollSmoother.create({
smooth: 1,
effects: false
});
}
//SLIDE APPS
if( $(window).width() > 1023 ) {
$(document).ready(function(e){
$("body").find("#showapps").hover(function() {
$("#customSizeModal").modal('show');
});
});
}
$('#customSizeModal').show('show', function() {
var inst = new Glide('.glide', {
type: 'carousel',
startAt: 0,
perView: 3,
focusAt: 'center',
gap: 16,
breakpoints: {
1200: {
perView: 2
},
800: {
perView: 1
}
}
})
inst.mount()
});
/* SWIPER */
$(document).ready(function() {
const swiper = new Swiper('.swiper-container', {
loop: true,
autoplay: {
disableOnInteraction: false, pauseOnMouseEnter: false, waitForTransition: false,
},
speed: 3000,
slidesPerView: 3,
spaceBetween: 0,
breakpoints: {
640: {
slidesPerView: 4,
spaceBetween: 10,
},
1024: {
slidesPerView: 8,
spaceBetween: 10,
},
},
});
});
//FADE SECTIONS
let sections = gsap.utils.toArray(".panel"),
currentSection = sections[0];
gsap.defaults({ overwrite: "auto", duration: 1.3 });
gsap.set("body", { height: sections.length * 100 + "%" });
let mm = gsap.matchMedia();
mm.add("(min-width: 768px)", () => {
sections.forEach((section, i) => {
ScrollTrigger.create({
trigger: "#fadeinout01",
pin: true,
start: (self) => (i === 0 ? "top top" : self.previous().end),
end: () => "+=" + innerHeight,
scrub: true,
toggleActions: "restart none reverse reset",
onToggle: (self) => self.isActive && setSection(section),
toggleClass: {targets: section, className: "active"}
});
});
});
mm.add("(max-width: 767px)", () => {
sections.forEach((section, i) => {
ScrollTrigger.create({
trigger: "#fadeinout01",
pin: true,
pinType: "fixed",
start: (self) => (i === 0 ? "top top" : self.previous().end),
end: () => "+=" + innerHeight,
scrub: true,
toggleActions: "restart none reverse reset",
onToggle: (self) => self.isActive && setSection(section),
toggleClass: {targets: section, className: "active"}
});
});
});
var userhasmuted = false;
function setSection(newSection) {
if (newSection !== currentSection) {
gsap.timeline().to(currentSection, { autoAlpha: 0, duration: 0.9 });
gsap.timeline().to(newSection, { autoAlpha: 1, duration: 0.9 });
currentSection = newSection;
if(currentSection.classList.contains('hassound')) {
if(userhasmuted == false){
$("#vsound").prop('muted', false);
$("#mute-video").addClass('unmute-video');
}
$('#mute-video').show();
}else{
if(userhasmuted == false){
$("#vsound").prop('muted', true);
$("#mute-video").removeClass('unmute-video');
}
$('#mute-video').hide();
};
//play video on active section
if(currentSection.classList.contains('active')) {
var allvideos = document.querySelectorAll('video');
for (var i = 0; i < allvideos.length; i++) {
allvideos[i].pause();
if(currentSection.dataset.videoplay == allvideos[i].dataset.videoplay) {
allvideos[i].play();
}
}
}
}
}
//play first videos - loader
$(document).ready(function () {
if(document.body.classList.contains('videosattop')){
var allvideos = document.querySelectorAll('video');
for (var i = 1; i < 5; i++) {
allvideos[i].play();
}
}
});
/* VIDEO MUTE BUTTON */
$(document).ready(function () {
$("#mute-video").click(function () {
if ($("#vsound").prop('muted')) {
$("#vsound").prop('muted', false);
$("#mute-video").addClass('unmute-video');
userhasmuted = false;
} else {
$("#vsound").prop('muted', true);
$("#mute-video").removeClass('unmute-video');
userhasmuted = true;
}
});
});
//RELOAD ON RESIZE
jQuery(function($){
var windowWidth = $(window).width();
var windowHeight = $(window).height();
$(window).resize(function() {
if(windowWidth != $(window).width() || windowHeight != $(window).height()) {
location.reload();
return;
}
});
});
//MOUSE SCROLL
document.getElementById("scrollmouse").addEventListener("click", function() {
let pageHeight = window.innerHeight;
window.scrollBy(0, pageHeight + 10);
});
//FOOTER
if($(window).width() > 1023){
var footer = $('.footer'),
extra = 0;
$(window).scroll(function() {
var scrolledLength = ( $(window).height() + extra ) + $(window).scrollTop(),
documentHeight = $(document).height();
if( scrolledLength >= documentHeight ) {
footer
.addClass('open');
document.getElementById("scrollmouse").style.visibility = "hidden";
document.getElementById("gcontainer").classList.add("opa02");
}
else if ( scrolledLength <= documentHeight && footer.hasClass('open') ) {
footer
.removeClass('open');
document.getElementById("scrollmouse").style.visibility = "visible";
document.getElementById("gcontainer").classList.remove("opa02");
}
});
}