1/** 2 * https://github.com/alumbo/jquery.parallax-scroll 3 * 4*/ 5(function( $ ) { 6 7 $( document ).ready( function() { 8 var ParallaxScroll = { 9 /* PUBLIC VARIABLES */ 10 showLogs: false, 11 round: 1000, 12 13 /* PUBLIC FUNCTIONS */ 14 init: function() { 15 this._log("init"); 16 if (this._inited) { 17 this._log("Already Inited"); 18 this._inited = true; 19 return; 20 } 21 this._requestAnimationFrame = (function(){ 22 return window.requestAnimationFrame || 23 window.webkitRequestAnimationFrame || 24 window.mozRequestAnimationFrame || 25 window.oRequestAnimationFrame || 26 window.msRequestAnimationFrame || 27 function(/* function */ callback, /* DOMElement */ element){ 28 window.setTimeout(callback, 1000 / 60); 29 }; 30 })(); 31 this._onScroll(true); 32 }, 33 34 /* PRIVATE VARIABLES */ 35 _inited: false, 36 _properties: ['x', 'y', 'z', 'rotateX', 'rotateY', 'rotateZ', 'scaleX', 'scaleY', 'scaleZ', 'scale'], 37 _requestAnimationFrame:null, 38 39 /* PRIVATE FUNCTIONS */ 40 _log: function(message) { 41 if (this.showLogs) console.log("Parallax Scroll / " + message); 42 }, 43 _onScroll: function(noSmooth) { 44 var scroll = $(document).scrollTop(); 45 var windowHeight = $(window).height(); 46 this._log("onScroll " + scroll); 47 $("[data-parallax]").each($.proxy(function(index, el) { 48 var $el = $(el); 49 50 //knight 51 if( ($el.hasClass('pxl-parallax-laptop-no') || $el.closest('.pxl-parallax-laptop-no').length > 0) && $(window).outerWidth() < 1600 ) 52 return; 53 if( ($el.hasClass('pxl-parallax-tablet_extra-no') || $el.closest('.pxl-parallax-tablet_extra-no').length > 0) && $(window).outerWidth() < 1200 ) 54 return; 55 if( ($el.hasClass('pxl-parallax-tablet-no') || $el.closest('.pxl-parallax-tablet-no').length > 0) && $(window).outerWidth() < 992 ) 56 return; 57 if( ($el.hasClass('pxl-parallax-mobile_extra-no') || $el.closest('.pxl-parallax-mobile_extra-no').length > 0) && $(window).outerWidth() < 768 ) 58 return; 59 if( ($el.hasClass('pxl-parallax-mobile-no') || $el.closest('.pxl-parallax-mobile-no').length > 0) && $(window).outerWidth() < 576 ) 60 return; 61 //end knight 62 63 var properties = []; 64 var applyProperties = false; 65 var style = $el.data("style"); 66 if (style == undefined) { 67 style = $el.attr("style") || ""; 68 $el.data("style", style); 69 } 70 var datas = [$el.data("parallax")]; 71 var iData; 72 for(iData = 2; ; iData++) { 73 if($el.data("parallax"+iData)) { 74 datas.push($el.data("parallax-"+iData)); 75 } 76 else { 77 break; 78 } 79 } 80 var datasLength = datas.length; 81 for(iData = 0; iData < datasLength; iData ++) { 82 var data = datas[iData]; 83 var scrollFrom = data["from-scroll"]; 84 if (scrollFrom == undefined) scrollFrom = Math.max(0, $(el).offset().top - (windowHeight * 0.6)); 85 scrollFrom = scrollFrom | 0; 86 var scrollDistance = data["distance"]; 87 var scrollTo = data["to-scroll"]; 88 if (scrollDistance == undefined && scrollTo == undefined) scrollDistance = windowHeight; 89 scrollDistance = Math.max(scrollDistance | 0, 1); 90 var easing = data["easing"]; 91 var easingReturn = data["easing-return"]; 92 if (easing == undefined || !$.easing|| !$.easing[easing]) easing = null; 93 if (easingReturn == undefined || !$.easing|| !$.easing[easingReturn]) easingReturn = easing; 94 if (easing) { 95 var totalTime = data["duration"]; 96 if (totalTime == undefined) totalTime = scrollDistance; 97 totalTime = Math.max(totalTime | 0, 1); 98 var totalTimeReturn = data["duration-return"]; 99 if (totalTimeReturn == undefined) totalTimeReturn = totalTime; 100 scrollDistance = 1; 101 var currentTime = $el.data("current-time"); 102 if(currentTime == undefined) currentTime = 0; 103 } 104 if (scrollTo == undefined) scrollTo = scrollFrom + scrollDistance; 105 scrollTo = scrollTo | 0; 106 var smoothness = data["smoothness"]; 107 if (smoothness == undefined) smoothness = 30; 108 smoothness = smoothness | 0; 109 if (noSmooth || smoothness == 0) smoothness = 1; 110 smoothness = smoothness | 0; 111 var scrollCurrent = scroll; 112 scrollCurrent = Math.max(scrollCurrent, scrollFrom); 113 scrollCurrent = Math.min(scrollCurrent, scrollTo); 114 if(easing) { 115 if($el.data("sens") == undefined) $el.data("sens", "back"); 116 if(scrollCurrent>scrollFrom) { 117 if($el.data("sens") == "back") { 118 currentTime = 1; 119 $el.data("sens", "go"); 120 } 121 else { 122 currentTime++; 123 } 124 } 125 if(scrollCurrent<scrollTo) { 126 if($el.data("sens") == "go") { 127 currentTime = 1; 128 $el.data("sens", "back"); 129 } 130 else { 131 currentTime++; 132 } 133 } 134 if(noSmooth) currentTime = totalTime; 135 $el.data("current-time", currentTime); 136 } 137 this._properties.map($.proxy(function(prop) { 138 var defaultProp = 0; 139 var to = data[prop]; 140 if (to == undefined) return; 141 if(prop=="scale" || prop=="scaleX" || prop=="scaleY" || prop=="scaleZ" ) { 142 defaultProp = 1; 143 } 144 else { 145 to = to | 0; 146 } 147 var prev = $el.data("_" + prop); 148 if (prev == undefined) prev = defaultProp; 149 var next = ((to-defaultProp) * ((scrollCurrent - scrollFrom) / (scrollTo - scrollFrom))) + defaultProp; 150 var val = prev + (next - prev) / smoothness; 151 if(easing && currentTime>0 && currentTime<=totalTime) { 152 var from = defaultProp; 153 if($el.data("sens") == "back") { 154 from = to; 155 to = -to; 156 easing = easingReturn; 157 totalTime = totalTimeReturn; 158 } 159 val = $.easing[easing](null, currentTime, from, to, totalTime); 160 }
161 val = Math.ceil(val * this.round) / this.round; 162 if(val==prev&&next==to) val = to; 163 if(!properties[prop]) properties[prop] = 0; 164 properties[prop] += val; 165 if (prev != properties[prop]) { 166 $el.data("_" + prop, properties[prop]); 167 applyProperties = true; 168 } 169 }, this)); 170 } 171 if (applyProperties) { 172 if (properties["z"] != undefined) { 173 var perspective = data["perspective"]; 174 if (perspective == undefined) perspective = 800; 175 var $parent = $el.parent(); 176 if(!$parent.data("style")) $parent.data("style", $parent.attr("style") || ""); 177 $parent.attr("style", "perspective:" + perspective + "px; -webkit-perspective:" + perspective + "px; "+ $parent.data("style")); 178 } 179 if(properties["scaleX"] == undefined) properties["scaleX"] = 1; 180 if(properties["scaleY"] == undefined) properties["scaleY"] = 1; 181 if(properties["scaleZ"] == undefined) properties["scaleZ"] = 1; 182 if (properties["scale"] != undefined) { 183 properties["scaleX"] *= properties["scale"]; 184 properties["scaleY"] *= properties["scale"]; 185 properties["scaleZ"] *= properties["scale"]; 186 } 187 188 var translate3d = "translate3d(" + (properties["x"] ? properties["x"] : 0) + "px, " + (properties["y"] ? properties["y"] : 0) + "px, " + (properties["z"] ? properties["z"] : 0) + "px)"; 189 var rotate3d = "rotateX(" + (properties["rotateX"] ? properties["rotateX"] : 0) + "deg) rotateY(" + (properties["rotateY"] ? properties["rotateY"] : 0) + "deg) rotateZ(" + (properties["rotateZ"] ? properties["rotateZ"] : 0) + "deg)"; 190 var scale3d = "scaleX(" + properties["scaleX"] + ") scaleY(" + properties["scaleY"] + ") scaleZ(" + properties["scaleZ"] + ")"; 191 var cssTransform = translate3d + " " + rotate3d + " " + scale3d + ";"; 192 this._log(cssTransform); 193 $el.attr("style", "transform:" + cssTransform + " -webkit-transform:" + cssTransform + " " + style); 194 } 195 }, this)); 196 197 if(window.requestAnimationFrame) { 198 window.requestAnimationFrame($.proxy(this._onScroll, this, false)); 199 } 200 else { 201 this._requestAnimationFrame($.proxy(this._onScroll, this, false)); 202 } 203 } 204 }; 205 //if($(window).innerWidth() >= 1200){ 206 ParallaxScroll.init(); 207 //} 208 }); 209})(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.