1(function($) { 2 3 $('a[href*="#"]').on('click', function(e) { 4 e.preventDefault() 5 $('html, body').animate({ 6 scrollTop: $($(this).attr('href')).offset().top - 80, 7 }, 8 1000, 9 'linear' 10 ) 11 }); 12 13 $('.navbar-nav>li>a').on('click', function() { 14 $('.navbar-collapse').collapse('hide'); 15 }); 16 17 $(window).on('scroll', (function() { 18 if ($(window).scrollTop() > 50) { 19 $('.header').addClass('header-sticky'); 20 } else { 21 $('.header').removeClass('header-sticky'); 22 } 23 })); 24 25 function Utils() {} 26 Utils.prototype = { 27 constructor: Utils, 28 isElementInView: function(element, fullyInView) { 29 var pageTop = $(window).scrollTop(); 30 var pageBottom = pageTop + $(window).height(); 31 var elementTop = $(element).offset().top; 32 var elementBottom = elementTop + $(element).height(); 33 34 if (fullyInView === true) { 35 return ((pageTop < elementTop) && (pageBottom > elementBottom)); 36 } else { 37 return ((elementTop <= pageBottom) && (elementBottom >= pageTop)); 38 } 39 } 40 }; 41 42 var Utils = new Utils(); 43 $(window).on('load', addFadeIn()); 44 45 $(window).scroll(function() { 46 addFadeIn(true); 47 }); 48 $(window).on('load', function() { 49 console.log('main banner loaded'); 50 addFadeIn(); 51 }); 52 53 function addFadeIn(repeat) { 54 var classToFadeIn = ".animated"; 55 56 $(classToFadeIn).each(function(index) { 57 var isElementInView = Utils.isElementInView($(this), false); 58 if (isElementInView) { 59 if (!($(this).hasClass('go')) && !($(this).hasClass('go'))) { 60 if (index % 2 == 0) $(this).addClass('go'); 61 else $(this).addClass('go'); 62 } 63 } else if (repeat) { 64 $(this).removeClass('go'); 65 } 66 }); 67 } 68 69 70 71 72 73 74 75 76 // $(window).on('scroll', function() { 77 // $(".animated").each(function() { 78 // if (isScrolledIntoView($(this))) { 79 // $(this).addClass("go"); 80 // console.log('this'); 81 // console.dir($(this)); 82 // } else { 83 // $(this).removeClass("go"); 84 // } 85 // }); 86 // }); 87 88 // function isScrolledIntoView(elem) { 89 // var docViewTop = $(window).scrollTop(); 90 // var docViewBottom = docViewTop + $(window).height(); 91 92 // var elemTop = $(elem).offset().top; 93 // var elemBottom = elemTop + $(elem).height(); 94 95 // return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); 96 // } 97 98 99 100 // const animateCSS = (element, animation, prefix = 'animate__') => 101 // // We create a Promise and return it 102 // new Promise((resolve, reject) => { 103 // const animationName = `${prefix}${animation}`; 104 // const node = document.querySelector(element); 105 106 // node.classList.add(`${prefix}animated`, animationName); 107 108 // // When the animation ends, we clean the classes and resolve the Promise 109 // function handleAnimationEnd(event) { 110 // event.stopPropagation(); 111 // node.classList.remove(`${prefix}animated`, animationName); 112 // resolve('Animation ended'); 113 // } 114 115 // node.addEventListener('animationend', handleAnimationEnd, {once: true}); 116 // }); 117 118 119 // //Add to on scroll check in and out 120 // // animateCSS('.my-element', 'bounce'); 121 122 // // // or 123 // // animateCSS('.my-element', 'bounce').then((message) => { 124 // // // Do something after the animation 125 // // }); 126 127 128})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.