Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/06/2017, 02:05
macaluan
 
Fecha de Ingreso: junio-2014
Mensajes: 70
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: menu canvas no funciona

Código Javascript:
Ver original
  1. ;(function () {
  2.    
  3.     'use strict';
  4.  
  5.  
  6.  
  7.     // iPad and iPod detection 
  8.     var isiPad = function(){
  9.         return (navigator.platform.indexOf("iPad") != -1);
  10.     };
  11.  
  12.     var isiPhone = function(){
  13.         return (
  14.             (navigator.platform.indexOf("<i></i>Phone") != -1) ||
  15.             (navigator.platform.indexOf("iPod") != -1)
  16.         );
  17.     };
  18.  
  19.     var fullHeight = function() {
  20.         if ( !isiPad() && !isiPhone() ) {
  21.             $('.js-fullheight').css('height', $(window).height());
  22.             $(window).resize(function(){
  23.                 $('.js-fullheight').css('height', $(window).height());
  24.             })
  25.         }
  26.     };
  27.  
  28.     var sliderMain = function() {
  29.        
  30.         $('#fh5co-home .flexslider').flexslider({
  31.             animation: "fade",
  32.             slideshowSpeed: 5000
  33.         });
  34.  
  35.         $('#fh5co-home .flexslider .slides > li').css('height', $(window).height());   
  36.         $(window).resize(function(){
  37.             $('#fh5co-home .flexslider .slides > li').css('height', $(window).height());   
  38.         });
  39.  
  40.         $('.js-fh5co-next').on('click', function(event){
  41.  
  42.             event.preventDefault();
  43.             $('html, body').animate({
  44.                 scrollTop: $(this).closest('#fh5co-home').next().offset().top
  45.             }, 800, 'easeOutExpo');
  46.            
  47.         });
  48.  
  49.     };
  50.  
  51.     var sliderTestimony = function() {
  52.  
  53.         $('#fh5co-testimony .flexslider').flexslider({
  54.             animation: "slide",
  55.             slideshowSpeed: 5000,
  56.             directionNav: false,
  57.             controlNav: true,
  58.             smoothHeight: true,
  59.             reverse: true
  60.         });
  61.  
  62.     }
  63.  
  64.     var offcanvasMenu = function() {
  65.  
  66.         $('body').prepend('<div id="fh5co-offcanvas" />');
  67.         $('#fh5co-offcanvas').append($('#fh5co-main-nav').clone());
  68.  
  69.         setTimeout(function(){
  70.             $('#fh5co-offcanvas').prepend('<a href="#" class="js-fh5co-offcanvas-close fh5co-offcanvas-close" />');
  71.             $('#fh5co-offcanvas #fh5co-main-nav').attr('id', '');
  72.         }, 200);
  73.        
  74.     };
  75.  
  76.     var mainMenuSticky = function() {
  77.        
  78.         var sticky = $('.js-sticky');
  79.  
  80.         sticky.css('height', sticky.height());
  81.         $(window).resize(function(){
  82.             sticky.css('height', sticky.height());
  83.         });
  84.  
  85.         var $section = $('.fh5co-main-nav');
  86.        
  87.         $section.waypoint(function(direction) {
  88.            
  89.             if (direction === 'down') {
  90.  
  91.                     $section.css({
  92.                         'position' : 'fixed',
  93.                         'top' : 0,
  94.                         'width' : '100%',
  95.                         'z-index' : 99999
  96.                     }).addClass('fh5co-shadow');;
  97.  
  98.             }
  99.  
  100.         }, {
  101.             offset: '0px'
  102.         });
  103.  
  104.         $('.js-sticky').waypoint(function(direction) {
  105.             if (direction === 'up') {
  106.                 $section.attr('style', '').removeClass('fh5co-shadow');
  107.             }
  108.         }, {
  109.             offset: function() { return -$(this.element).height() + 69; }
  110.         });
  111.  
  112.     };
  113.  
  114.     // Click outside of offcanvass
  115.     var mobileMenuOutsideClick = function() {
  116.  
  117.         $(document).click(function (e) {
  118.         var container = $("#fh5co-offcanvas, .js-fh5co-nav-toggle, .js-fh5co-offcanvas-close");
  119.         if (!container.is(e.target) && container.has(e.target).length === 0) {
  120.             if ( $('body').hasClass('offcanvas-visible') ) {
  121.  
  122.                 $('body').removeClass('fh5co-overflow offcanvas-visible');
  123.  
  124.                 $('.js-fh5co-nav-toggle').removeClass('active');
  125.             }
  126.         }
  127.         });
  128.  
  129.         $('body').on('click', '.js-fh5co-offcanvas-close', function(event){
  130.            
  131.             if ( $('body').hasClass('offcanvas-visible') ) {
  132.                 $('body').removeClass('fh5co-overflow offcanvas-visible');
  133.                 $('.js-fh5co-nav-toggle').removeClass('active');
  134.             }
  135.  
  136.             event.preventDefault();
  137.  
  138.         });
  139.  
  140.     };
  141.    
  142.     // Parallax
  143.     var parallax = function() {
  144.  
  145.         $(window).stellar();
  146.  
  147.     };
  148.  
  149.  
  150.     // Redirect page
  151.     var redirectPage = function(url) {
  152.        
  153.         window.location = url;
  154.  
  155.     }
  156.  
  157.     var pageTransition = function() {
  158.  
  159.         $("body").css("display", "none");
  160.        
  161.        
  162.         $("body").fadeIn(2000);
  163.        
  164.         $("a.transition").click(function(event){
  165.             event.preventDefault();
  166.             var linkLocation = this.href;
  167.  
  168.             $("body").fadeOut(2000, redirectPage);      
  169.            
  170.             redirectPage(linkLocation);
  171.         });
  172.            
  173.     };
  174.  
  175.  
  176.     // Burger Menu
  177.     var burgerMenu = function() {
  178.  
  179.         $('body').on('click', '.js-fh5co-nav-toggle', function(event){
  180.  
  181.             var $this = $(this);
  182.  
  183.             $('body').toggleClass('fh5co-overflow offcanvas-visible');
  184.             $this.toggleClass('active');
  185.             event.preventDefault();
  186.  
  187.         });
  188.  
  189.     };
  190.  
  191.     var scrolledWindow = function() {
  192.  
  193.         $(window).scroll(function(){
  194.  
  195.             var header = $('#fh5co-header'),
  196.                 scrlTop = $(this).scrollTop();
  197.  
  198.             if ( scrlTop > 500 && scrlTop <= 2000 ) {
  199.                 header.addClass('navbar-fixed-top fh5co-animated slideInDown');
  200.             } else if ( scrlTop <= 500) {
  201.                 if ( header.hasClass('navbar-fixed-top') ) {
  202.                     header.addClass('navbar-fixed-top fh5co-animated slideOutUp');
  203.                     setTimeout(function(){
  204.                         header.removeClass('navbar-fixed-top fh5co-animated slideInDown slideOutUp');
  205.                     }, 100 );
  206.                 }
  207.             }
  208.  
  209.            $('#fh5co-home .flexslider .fh5co-overlay').css({
  210.                 'opacity' : (.5)+(scrlTop/2000)
  211.            });
  212.  
  213.            if ( $('body').hasClass('offcanvas-visible') ) {
  214.             $('body').removeClass('offcanvas-visible');
  215.             $('.js-fh5co-nav-toggle').removeClass('active');
  216.            }
  217.          
  218.         });
  219.  
  220.         $(window).resize(function() {
  221.             if ( $('body').hasClass('offcanvas-visible') ) {
  222.             $('body').removeClass('offcanvas-visible');
  223.             $('.js-fh5co-nav-toggle').removeClass('active');
  224.            }
  225.         });
  226.        
  227.     };
  228.  
  229.  
  230.     var goToTop = function() {
  231.  
  232.         $('.js-gotop').on('click', function(event){
  233.            
  234.             event.preventDefault();
  235.  
  236.             $('html, body').animate({
  237.                 scrollTop: $('html').offset().top
  238.             }, 500);
  239.            
  240.             return false;
  241.         });
  242.    
  243.     };
  244.  
  245.  
  246.     // Page Nav
  247.     var clickMenu = function() {
  248.         var topVal = ( $(window).width() < 769 ) ? 0 : 58;
  249.  
  250.         $(window).resize(function(){
  251.             topVal = ( $(window).width() < 769 ) ? 0 : 58;     
  252.         });
  253.  
  254.         if ( $(this).attr('href') != "#") {
  255.             $('#fh5co-main-nav a:not([class="external"]), #fh5co-offcanvas a:not([class="external"])').click(function(event){
  256.                 var section = $(this).data('nav-section');
  257.  
  258.  
  259.                 if ( $('div[data-section="' + section + '"]').length ) {
  260.  
  261.                     $('html, body').animate({
  262.                         scrollTop: $('div[data-section="' + section + '"]').offset().top - topVal
  263.                     }, 500);   
  264.                    
  265.                }
  266.                event.preventDefault();
  267.  
  268.             });
  269.         }
  270.  
  271.        
  272.  
  273.  
  274.     };
  275.  
  276.     // Reflect scrolling in navigation
  277.     var navActive = function(section) {
  278.        
  279.         $('#fh5co-main-nav li, #fh5co-offcanvas li').removeClass('active');
  280.         $('#fh5co-main-nav, #fh5co-offcanvas').find('a[data-nav-section="'+section+'"]').closest('li').addClass('active');
  281.        
  282.     };
  283.  
  284.     var navigationSection = function() {
  285.  
  286.         var $section = $('div[data-section]');
  287.        
  288.         $section.waypoint(function(direction) {
  289.             if (direction === 'down') {
  290.                 navActive($(this.element).data('section'));
  291.             }
  292.  
  293.         }, {
  294.             offset: '150px'
  295.         });
  296.  
  297.         $section.waypoint(function(direction) {
  298.             if (direction === 'up') {
  299.                 navActive($(this.element).data('section'));
  300.             }
  301.         }, {
  302.             offset: function() { return -$(this.element).height() + 155; }
  303.         });
  304.  
  305.     };
  306.  
  307.  
  308.  
  309.     var contentWayPoint = function() {
  310.         var i = 0;
  311.         $('.animate-box').waypoint( function( direction ) {
  312.  
  313.             if( direction === 'down' && !$(this.element).hasClass('animated') ) {
  314.                
  315.                 i++;
  316.  
  317.                 $(this.element).addClass('item-animate');
  318.                 setTimeout(function(){
  319.                    
  320.                     $('body .animate-box.item-animate').each(function(k){
  321.                         var el = $(this);
  322.                         setTimeout( function () {
  323.                             el.addClass('fadeInUp animated');
  324.                             el.removeClass('item-animate');
  325.                         },  k * 200, 'easeInOutExpo' );
  326.                     });
  327.                    
  328.                 }, 100);
  329.                
  330.             }
  331.  
  332.         } , { offset: '85%' } );
  333.  
  334.  
  335.     };
  336.  
  337.  
  338.     // Document on load.
  339.     $(function(){
  340.  
  341.         pageTransition();
  342.         fullHeight();
  343.         sliderMain();
  344.         sliderTestimony();
  345.         offcanvasMenu();
  346.         mainMenuSticky();
  347.         mobileMenuOutsideClick();
  348.         parallax();
  349.         burgerMenu();
  350.         scrolledWindow();
  351.         clickMenu();
  352.         navigationSection();
  353.         goToTop();
  354.        
  355.  
  356.  
  357.         // Animations
  358.         contentWayPoint();
  359.        
  360.        
  361.  
  362.     });
  363.  
  364.  
  365. }());