1/* Aura version: 1.8.6 */ 2 3/* 4 Plugin: PI Parallax 5 Version 1.0.0 6 Author: Pavel Shlykov 7 8 Dual licensed under the MIT and GPL licenses: 9 http://www.opensource.org/licenses/mit-license.php 10 http://www.gnu.org/licenses/gpl.html 11 */ 12 13jQuery(function($) { 14 var $w = $(window), 15 $d = $(document), 16 windowHeight = $w.height(), 17 elements = []; 18 19 $w.resize(function () { 20 windowHeight = $w.height(); 21 }); 22 23 $.fn.parallax = function () { 24 25 $(this).each(function () { 26 27 var $el = $(this), 28 el = { 29 $el: $el, 30 t: $el.offset().top, 31 x: $el.data('parallaxX') || '50%', 32 y: $el.data('parallaxY') || 0, 33 s: $el.data('parallaxSpeed') || 0.5, 34 h: getHeight($el, ($el.data('parallaxOuterHeight') || 1)) 35 }; 36 37 elements.push(el); 38 39 }); 40 41 }; 42 43 $d.on('piBoundChanged', function(){ 44 checkParallaxState(); 45 }); 46 checkParallaxState(); 47 48 function checkParallaxState(){ 49 if(window.piCurrentBound == 'lg'){ 50 enableParallax(); 51 } else { 52 disableParallax(); 53 } 54 } 55 56 function update() { 57 var scrollTop = $w.scrollTop(); 58 59 for (var i = 0; i < elements.length; i++) { 60 var o = elements[i]; 61 o.t = o.$el.offset().top; 62 o.h = getHeight(o.$el, 1); 63 64 if (o.t + o.h > scrollTop && o.t < scrollTop + windowHeight) { 65 o.$el.css('backgroundPosition', o.x + " " + Math.round((o.t - scrollTop + o.y) * o.s) + "px"); 66 } 67 } 68 } 69 70 function getHeight($el, outerHeight) { 71 if (outerHeight) { 72 return $el.outerHeight(true); 73 } else { 74 return $el.height(); 75 } 76 } 77 78 function enableParallax(){ 79 $w.on('scroll.piParallax resize.piParallax', update); 80 update(); 81 } 82 83 function disableParallax(){ 84 $w.off('scroll.piParallax resize.piParallax'); 85 for (var i = 0; i < elements.length; i++) { 86 var o = elements[i]; 87 o.$el.css('backgroundPosition', ''); 88 } 89 } 90 91 92});
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.