vendor: 2,360 bytes, lines 1-87
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(root, factory) { 8 if (typeof define === 'function' && define.amd) { 9 define(['jquery'], factory); 10 } else { 11 factory(root.jQuery); 12 } 13}(this, function($) { 14 'use strict'; 15 16 // Create the defaults once 17 var pluginName = 'scrolly', 18 defaults = { 19 bgParallax: false 20 }, 21 didScroll = false; 22 23 function Plugin( element, options ) { 24 this.element = element; 25 this.$element = $(this.element); 26 27 this.options = $.extend( {}, defaults, options) ; 28 29 this._defaults = defaults; 30 this._name = pluginName; 31 32 this.init(); 33 } 34 35 Plugin.prototype.init = function () { 36 var self = this; 37 this.startPosition = this.$element.position().top; 38 this.offsetTop = this.$element.offset().top; 39 this.height = this.$element.outerHeight(true); 40 this.velocity = this.$element.attr('data-velocity'); 41 this.bgStart = parseInt(this.$element.attr('data-fit'), 10); 42 43 $(document).scroll(function(){ 44 self.didScroll = true; 45 }); 46 47 setInterval(function() { 48 if (self.didScroll) { 49 self.didScroll = false; 50 self.scrolly(); 51 } 52 }, 10); 53 }; 54 55 Plugin.prototype.scrolly = function() { 56 var dT = $(window).scrollTop(), 57 wH = $(window).height(), 58 position = this.startPosition; 59 60 if(this.offsetTop >= (dT+wH)) { 61 this.$element.addClass('scrolly-invisible'); 62 } else { 63 if(this.$element.hasClass('scrolly-invisible')){ 64 position = this.startPosition + (dT + ( wH - this.offsetTop ) ) * this.velocity; 65 } else { 66 position = this.startPosition + dT * this.velocity; 67 } 68 } 69 // Fix background position 70 if(this.bgStart){ position = position + this.bgStart; } 71 72 if(this.options.bgParallax === true) { 73 this.$element.css({backgroundPosition: '50% '+position+'px'}); 74 } else { 75 this.$element.css({top: position}); 76 } 77 }; 78 79 $.fn[pluginName] = function ( options ) { 80 return this.each(function () { 81 if (!$.data(this, 'plugin_' + pluginName)) { 82 $.data(this, 'plugin_' + pluginName, new Plugin( this, options )); 83 } 84 }); 85 }; 86 87});
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.