contador = 0; $(function(){ $('.menu_bar, #back, .cerrar, nav a').click(function(){ if($(window).width() < 768){ if(contador == 1){ $('.menu_bar').removeClass('no-pulled').addClass('pulled'); $('nav').animate({right:'0'}); setTimeout(function() { $('#back').fadeIn(); },300); contador = 0; } else{ $('.menu_bar').removeClass('pulled').addClass('no-pulled'); contador = 1; $('#back').fadeOut(); setTimeout(function() { $('nav').animate({right:'-120%'}); },300); } } }); }); $(function(){ $('body').on('swiperight', swiperightHandler); $('body').on('swipeleft',swipeleftHandler); $('#shopping_cart').click(clickPull); function clickPull() { var btn = $('#shopping_cart'); if($(btn).hasClass('pulled')) { swipeleftHandler(); } else { swiperightHandler(); } } function swiperightHandler(event){ $('#main-content').animate({marginRight:'40%',marginLeft:'-40%'}, 400); $('#main-cart').animate({marginRight:'0%'}, 400); $('#shopping_cart').removeClass('no-pulled').addClass('pulled'); } function swipeleftHandler(event){ $('#main-content').animate({marginRight:'0%',marginLeft:'0%'}, 400); $('#main-cart').animate({marginRight:'-40%'}, 400); $('#shopping_cart').removeClass('pulled').addClass('no-pulled'); } }); // Header sticky $(document).ready(header_sticky); $(window).scroll(header_sticky); function header_sticky(){ if ($(window).scrollTop() >= $('header').outerHeight()) { $('#up_btn').fadeIn(); $('header').addClass('fixed-header'); } else { $('#up_btn').fadeOut(); $('header').removeClass('fixed-header'); } }; // Ease scroll $('nav a, .anchor-btn').click(function(e) { e.preventDefault(); var anchor = $(this).attr('data-src'); var offset = $(anchor).offset().top; $('body,html').animate({scrollTop:offset},300,'swing'); }); // Anchor items $(window).on('scroll', function() { $('.anchor-item').each(function() { var s = $(window).scrollTop() + 105; var a = $(this).offset().top; if(s>=a){ $('nav a').removeClass('current-nav'); $('nav a[data-src="#'+$(this).attr('id')+'"]').addClass('current-nav'); } }); }); // Bloques iguales $(document).ready(function() { if ($('.BlockSize').length){ function blockHeight() { generalHeight = 0; i = 1; counter = 1; if ($(window).width() >= 480){ if ($(window).width() > 960) {blqNum = 3} else if ($(window).width() >= 480) {blqNum = 2} $('.BlockSize').css({height:'auto'}); $('.BlockSize').each(function(){ $(this).attr('data-grup',i); if (counter >= blqNum) {i++;counter = 0;} counter++; }); i = 1; counter = 1; $('.BlockSize').each(function(){ thisHeight = $(this).height(); thisPrev = $(this).prev('.BlockSize[data-grup="'+i+'"]'); prevHeight = $(thisPrev).height(); thisNext = $(this).next('.BlockSize[data-grup="'+i+'"]'); nextHeight = $(thisNext).height(); if (generalHeight < thisHeight) {generalHeight = thisHeight} if (counter >= blqNum) { $('.BlockSize[data-grup="'+i+'"]').height(generalHeight); i++; counter = 0; generalHeight = 0; } else if(counter != 1){ if (thisHeight > prevHeight) {$(thisPrev).height(generalHeight)} } else{ if (thisHeight > nextHeight) {$(thisNext).height(generalHeight)} } counter++; }); } else{ $('.BlockSize').css({height:'auto'}); } }; $(window).on('load',blockHeight); $(window).on('resize',blockHeight); $(window).on('orientationc',blockHeight); } }); function animation() { winHeight = 0.75 * $(window).height(); winOffset = $(window).scrollTop() + winHeight; $('.animated').each(function() { $(this).addClass('newAnimated'); }); $('.newAnimated').each(function() { if($(this).offset().top <= winOffset){ $(this).addClass('AnimateActive'); } }); } $(document).ready(animation); $(window).on('load',animation).resize(animation).scroll(animation).on('orientationchange',animation); // Posicionador de Footer $(document).ready(function() { var footerHeight = 0, footerTop = 0, $footer = $("footer"); positionFooter(); function positionFooter() { $footer.css({position: "static"}); footerHeight = $footer.height(); footerTop = ($(window).height())+"px"; if ( ($(document.body).height()) < $(window).height()) { $footer.css({ position: "absolute" }).animate({ bottom: 0 },-1) } else { $footer.css({ position: "static" }) } } $(window).on('load',positionFooter); $(window).on('resize',positionFooter); $(window).on('orientationchange',positionFooter); });