1(function($) { 2 "use strict"; 3 4 $.fn.parallax = function(options) { 5 6 var windowHeight = $(window).height(); 7 8 var settings = $.extend({ 9 velocity: 0.15, 10 offset: 0 11 }, options); 12 13 return this.each(function() { 14 15 var element = $(this); 16 var velocity = ($(this).data("velocity") ? $(this).data("velocity") : settings.velocity); 17 var img_offset = ($(this).data("offset") ? $(this).data("offset") : settings.offset); 18 var no_repeat = ($(this).data("no-repeat") ? $(this).data("no-repeat") : false); 19 20 // background image 21 if($(this).data('image')){ 22 $(this).css("background-image", "url(" + $(this).data('image') + ")"); 23 } 24 25 // if no repeat is set then get height 26 if(no_repeat){ 27 var image_url = $(element).css("background-image").replace('url(','').replace(')',''); 28 $("<img/>").attr("src", image_url).load(function() { 29 image_height = this.height; 30 div_height = element.height(); 31 }); 32 } 33 34 $(document).scroll(function() { 35 36 var scrollTop = $(window).scrollTop(); 37 var offset = element.offset().top; 38 var out_height = element.outerHeight(); 39 var height = $(window).height(); 40 41 if (offset + out_height <= scrollTop || offset >= scrollTop + windowHeight) { 42 return; 43 } 44 45 //var new_position = Math.round(((offset - (scrollTop + height)) * velocity) + img_offset); 46 var new_position = Math.round(((scrollTop + ( height - offset ) ) * velocity) + img_offset); 47 48 if((typeof image_height != "undefined") && (Math.abs(new_position) + div_height) > image_height){ 49 return; 50 } 51 52 element.css('background-position', '50% ' + new_position + 'px'); 53 54 }); 55 }); 56 } 57})(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.