vendor: 2,454 bytes, lines 1-79
1/* 2 * Project: Scrolly : parallax is easy as a matter of fact ! 3 * Description: Based on jQuery boilerplate 4 * Author: Victor C. / Octave & Octave web agency 5 * Licence: MIT 6 */ 7(function ( $, window, document, undefined ) { 8 // Create the defaults once 9 var pluginName = 'scrolly', 10 defaults = { 11 bgParallax: false 12 }, 13 didScroll = false; 14 15 function Plugin( element, options ) { 16 this.element = element; 17 this.$element = $(this.element); 18 19 this.options = $.extend( {}, defaults, options) ; 20 21 this._defaults = defaults; 22 this._name = pluginName; 23 24 this.init(); 25 } 26 27 Plugin.prototype.init = function () { 28 var self = this; 29 this.startPosition = this.$element.position().top; 30 this.offsetTop = this.$element.offset().top; 31 this.height = this.$element.outerHeight(true); 32 this.velocity = this.$element.attr('data-velocity'); 33 this.bgStart = parseInt(this.$element.attr('data-fit'), 10); 34 35 $(document).scroll(function(){ 36 self.didScroll = true; 37 }); 38 39 setInterval(function() { 40 if (self.didScroll) { 41 self.didScroll = false; 42 self.scrolly(); 43 } 44 }, 10); 45 }; 46 47 Plugin.prototype.scrolly = function() { 48 var dT = $(window).scrollTop(), 49 wH = $(window).height(), 50 position = this.startPosition; 51 52 if(this.offsetTop >= (dT+wH)) { 53 this.$element.addClass('scrolly-invisible'); 54 } else { 55 if(this.$element.hasClass('scrolly-invisible')){ 56 position = this.startPosition + (dT + ( wH - this.offsetTop ) ) * this.velocity; 57 } else { 58 position = this.startPosition + dT * this.velocity; 59 } 60 } 61 // Fix background position 62 if(this.bgStart){ position = position + this.bgStart; } 63 64 if(this.options.bgParallax === true) { 65 this.$element.css({backgroundPosition: '50% '+position+'px'}); 66 } else { 67 this.$element.css({top: position}); 68 } 69 }; 70 71 $.fn[pluginName] = function ( options ) { 72 return this.each(function () { 73 if (!$.data(this, 'plugin_' + pluginName)) { 74 $.data(this, 'plugin_' + pluginName, new Plugin( this, options )); 75 } 76 }); 77 }; 78 79})(jQuery, window, document);
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.