1jQuery(document).ready(function($) { "use strict"; 2 3/* detect touch */ 4if("ontouchstart" in window){ 5 document.documentElement.className = document.documentElement.className + " touch"; 6} 7if(!$("html").hasClass("touch")){ 8 /* background fix */ 9 $(".parallax").css("background-attachment", "fixed"); 10} 11 12/* resize background images */ 13function backgroundResize(){ 14 var windowH = $(window).height(); 15 $(".background").each(function(i){ 16 var path = $(this); 17 // variables 18 var contW = path.width(); 19 var contH = path.height(); 20 var imgW = path.attr("data-img-width"); 21 var imgH = path.attr("data-img-height"); 22 var ratio = imgW / imgH; 23 // overflowing difference 24 var diff = parseFloat(path.attr("data-diff")); 25 diff = diff ? diff : 0; 26 // remaining height to have fullscreen image only on parallax 27 var remainingH = 0; 28 if(path.hasClass("parallax") && !$("html").hasClass("touch")){ 29 var maxH = contH > windowH ? contH : windowH; 30 remainingH = windowH - contH; 31 } 32 // set img values depending on cont 33 imgH = contH + remainingH + diff; 34 imgW = imgH * ratio; 35 // fix when too large 36 if(contW > imgW){ 37 imgW = contW; 38 imgH = imgW / ratio; 39 } 40 // 41 path.data("resized-imgW", imgW); 42 path.data("resized-imgH", imgH); 43 path.css("background-size", imgW + "px " + imgH + "px"); 44 }); 45} 46$(window).resize(backgroundResize); 47$(window).focus(backgroundResize); 48backgroundResize(); 49 50/* set parallax background-position */ 51function parallaxPosition(e){ 52 var heightWindow = $(window).height(); 53 var topWindow = $(window).scrollTop(); 54 var bottomWindow = topWindow + heightWindow; 55 var currentWindow = (topWindow + bottomWindow) / 2; 56 $(".parallax").each(function(i){ 57 var path = $(this); 58 var height = path.height(); 59 var top = path.offset().top; 60 var bottom = top + height; 61 // only when in range 62 if(bottomWindow > top && topWindow < bottom){ 63 var imgW = path.data("resized-imgW"); 64 var imgH = path.data("resized-imgH"); 65 // min when image touch top of window 66 var min = 0; 67 // max when image touch bottom of window 68 var max = - imgH + heightWindow; 69 // overflow changes parallax 70 var overflowH = height < heightWindow ? imgH - height : imgH - heightWindow; // fix height on overflow 71 top = top - overflowH; 72 bottom = bottom + overflowH; 73 // value with linear interpolation 74 var value = min + (max - min) * (currentWindow - top) / (bottom - top); 75 // set background-position 76 var orizontalPosition = path.attr("data-oriz-pos"); 77 orizontalPosition = orizontalPosition ? orizontalPosition : "50%"; 78 $(this).css("background-position", orizontalPosition + " " + value + "px"); 79 } 80 }); 81} 82if(!$("html").hasClass("touch")){ 83 $(window).resize(parallaxPosition); 84 //$(window).focus(parallaxPosition); 85 $(window).scroll(parallaxPosition); 86 parallaxPosition(); 87} 88 89});
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.