1// #################################################################################### 2// ####### ####### 3// ####### Plugin: jScroll ####### 4// ####### Author: William Duffy ####### 5// ####### Website: http://www.wduffy.co.uk/jScroll ####### 6// ####### Version: 1.1 ####### 7// ####### ####### 8// ####### Copyright (c) 2011, William Duffy - www.wduffy.co.uk ####### 9// ####### ####### 10// ####### Permission is hereby granted, free of charge, to any person ####### 11// ####### obtaining a copy of this software and associated documentation ####### 12// ####### files (the "Software"), to deal in the Software without ####### 13// ####### restriction, including without limitation the rights to use, ####### 14// ####### copy, modify, merge, publish, distribute, sublicense, and/or sell ####### 15// ####### copies of the Software, and to permit persons to whom the ####### 16// ####### Software is furnished to do so, subject to the following ####### 17// ####### conditions: ####### 18// ####### ####### 19// ####### The above copyright notice and this permission notice shall be ####### 20// ####### included in all copies or substantial portions of the Software. ####### 21// ####### ####### 22// ####### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ####### 23// ####### EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ####### 24// ####### OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ####### 25// ####### NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ####### 26// ####### HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ####### 27// ####### WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ####### 28// ####### FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ####### 29// ####### OTHER DEALINGS IN THE SOFTWARE. ####### 30// ####### ####### 31// #################################################################################### 32(function($) { 33 34 // Public: jScroll Plugin 35 $.fn.jScroll = function(options) { 36 37 var opts = $.extend({}, $.fn.jScroll.defaults, options); 38 39 return this.each(function() { 40 var $element = $(this); 41 var $window = $(window); 42 var locator = new location($element); 43 var didScroll = false; 44 var timer = false; 45 46 // http://ejohn.org/blog/learning-from-twitter/ 47 $(window).scroll(function() { 48 if(!didScroll) { 49 timer = setInterval(function() { 50 if ( didScroll ) { 51 didScroll = false; 52 clearTimeout(timer); 53 $element 54 .stop() 55 .animate(locator.getMargin($window), opts.speed); 56 } 57 }, 250); 58 } 59 didScroll = true; 60 }); 61 }); 62 63 // Private 64 function location($element) 65 { 66 this.min = $element.offset().top; 67 this.originalMargin = parseInt($element.css("margin-top"), 10) || 0; 68 69 this.getMargin = function ($window) 70 { 71 var max = $element.parent().height() - $element.outerHeight(); 72 var margin = this.originalMargin; 73 74 if ($window.scrollTop() >= this.min - opts.top) 75 margin = margin + opts.top + $window.scrollTop() - this.min; 76 77 if (margin > max) 78 margin = max; 79 80 return ({"marginTop" : margin + 'px'}); 81 } 82 } 83 84 }; 85 86 // Public: Default values 87 $.fn.jScroll.defaults = { 88 speed : "slow", 89 top : 10 90 }; 91 92})(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.