1 2/* 3 Plugin: jQuery Parallax 4 Version 1.1.3 5 Author: Ian Lunn 6 Twitter: @IanLunn 7 Author URL: http://www.ianlunn.co.uk/ 8 Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ 9 10 Dual licensed under the MIT and GPL licenses: 11 http://www.opensource.org/licenses/mit-license.php 12 http://www.gnu.org/licenses/gpl.html 13 */ 14 15(function( $ ){ 16 "use strict"; 17 18 var $window = $(window); 19 var windowHeight = $window.height(); 20 21 $window.on('resize', function () { 22 windowHeight = $window.height(); 23 }); 24 25 $.fn.parallax = function(xpos, speedFactor, outerHeight) { 26 var $this = $(this); 27 var getHeight; 28 var firstTop; 29 var paddingTop = 0; 30 31 $this.each(function(){ 32 firstTop = $this.offset().top; 33 }); 34 35 if (outerHeight) { 36 getHeight = function(jqo) { 37 return jqo.outerHeight(true); 38 }; 39 } else { 40 getHeight = function(jqo) { 41 return jqo.height(); 42 }; 43 } 44 45 if (arguments.length < 1 || xpos === null) xpos = "50%"; 46 if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; 47 if (arguments.length < 3 || outerHeight === null) outerHeight = true; 48 49 function update(){ 50 var pos = $window.scrollTop(); 51 52 $this.each(function(){ 53 var $element = $(this); 54 var top = $element.offset().top; 55 var height = getHeight($element); 56 57 if (top + height < pos || top > pos + windowHeight) { 58 return; 59 } 60 61 $this.css('backgroundPosition', xpos + " " + Math.round((top - pos) * speedFactor) + "px"); 62 }); 63 } 64 65 $window.on('scroll', update).on('resize', update); 66 update(); 67 }; 68})(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.