1/* 2 Plugin: jQuery Parallax 3 Version 1.1.3 4 Author: Ian Lunn 5 Twitter: @IanLunn 6 Author URL: http://www.ianlunn.co.uk/ 7 Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ 8 Dual licensed under the MIT and GPL licenses: 9 http://www.opensource.org/licenses/mit-license.php 10 http://www.gnu.org/licenses/gpl.html 11 */ 12(function( $ ){ 13 var $window = jQuery(window); 14 var windowHeight = $window.height(); 15 $window.resize(function () { 16 windowHeight = $window.height(); 17 }); 18 jQuery.fn.vparallax = function(xpos, speedFactor, outerHeight) { 19 var $this = jQuery(this); 20 var getHeight; 21 var firstTop; 22 var paddingTop = 0; 23 //get the starting position of each element to have parallax applied to it 24 /*$this.each(function(){ 25 //firstTop = $this.offset().top; 26 });*/ 27 if (outerHeight) { 28 getHeight = function(jqo) { 29 return jqo.outerHeight(true); 30 }; 31 } else { 32 getHeight = function(jqo) { 33 return jqo.height(); 34 }; 35 } 36 // setup defaults if arguments aren't specified 37 if (arguments.length < 1 || xpos === null) xpos = "50%"; 38 if (arguments.length < 2 || speedFactor === null) speedFactor = 0.5; 39 if (arguments.length < 3 || outerHeight === null) outerHeight = true; 40 //speedFactor = (jQuery(this).data('parallax_sense'))/100; 41 // function to be called whenever the window is scrolled or resized 42 function update(){ 43 var pos = $window.scrollTop(); 44 $this.each(function(){ 45 firstTop = jQuery(this).offset().top; 46 var $element = jQuery(this); 47 var top = $element.offset().top; 48 var height = getHeight($element); 49 // Check if totally above or totally below viewport 50 if (top + height < pos || top > pos + windowHeight) { 51 return; 52 } 53 var f = Math.round((firstTop - pos) * speedFactor); 54 //if(firstTop >= windowHeight){ 55 //f = -f-(speedFactor*windowHeight); 56 //}else{ 57 f=-f; 58 //} 59 if(jQuery(this).parent().hasClass('vcpb-mlvp-jquery')) 60 var is_img_parallax_disable_on_mobile = jQuery(this).parent().parent().data('img-parallax-mobile-disable').toString(); 61 else 62 var is_img_parallax_disable_on_mobile = jQuery(this).parent().data('img-parallax-mobile-disable').toString(); 63 if(! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) 64 var is_mobile = 'false'; 65 else 66 var is_mobile = 'true'; 67 if(is_img_parallax_disable_on_mobile=='true' && is_mobile=='true') 68 var disable_row_parallax_effect = 'true'; 69 else 70 var disable_row_parallax_effect = 'false'; 71 72 if(disable_row_parallax_effect == 'false') 73 { 74 //f = -f; 75 jQuery(this).css('backgroundPosition', xpos + " " + f + "px"); 76 } 77 }); 78 } 79 $window.bind('scroll', update).resize(update); 80 update(); 81 }; 82 jQuery.fn.hparallax = function(xpos, speedFactor, outerHeight) { 83 var $this = jQuery(this); 84 var getHeight; 85 var firstTop; 86 var paddingTop = 0; 87 if (outerHeight) { 88 getHeight = function(jqo) { 89 return jqo.outerHeight(true); 90 }; 91 } else { 92 getHeight = function(jqo) { 93 return jqo.height(); 94 }; 95 } 96 // setup defaults if arguments aren't specified 97 if (arguments.length < 1 || xpos === null) xpos = "50%"; 98 if (arguments.length < 2 || speedFactor === null) speedFactor = 0.5; 99 if (arguments.length < 3 || outerHeight === null) outerHeight = true; 100 speedFactor = (jQuery(this).data('parallax_sense'))/100; 101 xpos = '0px'; 102 var prev_pos = $window.scrollTop(); 103 // function to be called whenever the window is scrolled or resized 104 function update(){ 105 106 var pos = $window.scrollTop(); 107 $this.each(function(){ 108 firstTop = jQuery(this).offset().top; 109 var $element = jQuery(this); 110 var top = $element.offset().top; 111 var height = getHeight($element); 112 if (top + height < pos || top > pos + windowHeight) { 113 return; 114 } 115 var bg = jQuery(this).css('backgroundPosition'); 116 var pxpos = bg.indexOf('px'); 117 var bgxpos= bg.substring(0,pxpos); 118 var f =0; 119 if(prev_pos-pos <= 0){ 120 f = parseInt(bgxpos) - parseInt(speedFactor*(Math.abs(prev_pos-pos))); 121 } 122 else{ 123 f = parseInt( bgxpos ) + parseInt( speedFactor * ( prev_pos - pos ) ); 124 125 if(f>0) 126 f=0; 127 } 128 var is_img_parallax_disable_on_mobile = jQuery(this).parent().data('img-parallax-mobile-disable').toString(); 129 if(! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) 130 var is_mobile = 'false'; 131 else 132 var is_mobile = 'true'; 133 if(is_mobile == 'true' && is_img_parallax_disable_on_mobile == 'true') 134 var disable_row_effect = 'true'; 135 else 136 var disable_row_effect = 'false'; 137 138 if(disable_row_effect == 'false') 139 { 140 jQuery(this).css('backgroundPosition', f + "px "+ xpos); 141 } 142 /*if(this).hasClass('upb_bg_size_automatic'){ 143 jQuery(this).each(function(){ 144 var vh = jQuery(window).outerHeight(); 145 var bh = jQuery(this).parent().outerHeight(); 146 var speed = jQuery(this).data('parallax_sense'); 147 var bw = jQuery(this).outerWidth() 148 var ih = (((vh+bh)/100)*speed)+bw; 149 jQuery(this).css('background-size',ih+'px auto'); 150 }) 151 }*/ 152 }); 153 prev_pos = pos; 154 } 155 $window.bind('scroll', update).resize(update); 156 update(); 157 }; 158})(jQuery); 159 // Auto Initialization 160 //if( ! jQuery.browser.mobile){ 161 jQuery(window).load(function(){ 162 163 if(! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) 164 var is_mobile = 'false'; 165 else 166 var is_mobile = 'true'; 167 168 jQuery('.vcpb-mlvp-jquery').each(function(){ 169 var selector = jQuery(this); 170 //var sense = selector.data('parallax_sense'); 171 //var incr =(selector.outerWidth()*(sense/100));
172 var img_list = selector.data('img-array'); 173 img_list = img_list.split(','); 174 var img_list_len = img_list.length; 175 for (var i = 0; i < img_list_len; i++) { 176 jQuery(selector).prepend('<div class="vertical_layer_parallax" style="position:absolute;background-image:url('+img_list[i]+');"></div>') 177 }; 178 var hp = jQuery(selector).find('.vertical_layer_parallax'); 179 hp.css({'max-width':'none','position':'absolute'}); 180 //hp.css('min-width',(hp.parent().outerWidth())+incr+'px'); 181 }); 182 jQuery('.vcpb-mlvp-jquery').each(function(){ 183 var layer_count = jQuery(this).find('.vertical_layer_parallax').length; 184 var sense = parseInt(jQuery(this).data('parallax_sense'))/100; 185 var is_img_parallax_disable_on_mobile = jQuery(this).parent().data('img-parallax-mobile-disable').toString(); 186 layer_count = (sense)/layer_count; 187 sense = 0; 188 189 if(is_mobile == 'true' && is_img_parallax_disable_on_mobile == 'true') 190 var disable_row_effect = 'true'; 191 else 192 var disable_row_effect = 'false'; 193 194 jQuery(this).find('.vertical_layer_parallax').each(function(index){ 195 sense += layer_count; 196 jQuery(this).css({'height':jQuery(this).parent().outerHeight()+'px','width':jQuery(this).parent().outerWidth()+'px',}). 197 attr('data-p-sense',sense); 198 if(disable_row_effect == 'false') 199 jQuery(this).vparallax("0%",sense); 200 }) 201 }) 202 //jQuery('.vcpb-vz-jquery').vparallax(); 203 jQuery('.vcpb-vz-jquery').each(function(){ 204 var is_img_parallax_disable_on_mobile = jQuery(this).parent().data('img-parallax-mobile-disable'); 205 if(is_mobile == 'true' && is_img_parallax_disable_on_mobile == 'true') 206 var disable_row_effect = 'true'; 207 else 208 var disable_row_effect = 'false'; 209 if(disable_row_effect == 'false') 210 jQuery(this).vparallax("50%",jQuery(this).data('parallax_sense')/100); 211 }) 212 jQuery('.vcpb-hz-jquery').hparallax(); 213 if(jQuery('.vcpb-hz-jquery').length>0){ 214 setTimeout(function() { 215 jQuery(window).scrollTop(0); 216 }, 1000); 217 } 218 }) 219//}
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.