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 9 Dual licensed under the MIT and GPL licenses: 10 http://www.opensource.org/licenses/mit-license.php 11 http://www.gnu.org/licenses/gpl.html 12 */ 13(function ($) { 14 "use strict"; 15 var $window = $(window); 16 var windowHeight = $window.height(); 17 $window.resize(function () { 18 windowHeight = $window.height(); 19 }); 20 $.fn.parallax = function (xpos, speedFactor, outerHeight) { 21 var $this = $(this); 22 var getHeight; 23 var firstTop; 24 var paddingTop = 0; 25 $this.each(function () { 26 firstTop = $this.offset().top; 27 }); 28 if (outerHeight) { 29 getHeight = function (jqo) { 30 return jqo.outerHeight(true); 31 }; 32 } else { 33 getHeight = function (jqo) { 34 return jqo.height(); 35 }; 36 } 37 if (arguments.length < 1 || xpos === null) xpos = "50%"; 38 if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; 39 if (arguments.length < 3 || outerHeight === null) outerHeight = true; 40 function update() { 41 var pos = $window.scrollTop(); 42 $this.each(function () { 43 var $element = $(this); 44 var top = $element.offset().top; 45 var height = getHeight($element); 46 if (top + height < pos || top > pos + windowHeight) { 47 return; 48 } 49 $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); 50 }); 51 } 52 53 $window.bind('scroll', update).resize(update); 54 update(); 55 }; 56})(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.