1(function ($) { 2 3 $.fn.transformParallaxFluid = function (options) { 4 5 $(this).each(function () { 6 7 8 var settings = $.extend({ 9 speed: 1.2, // 1 = default page speed, parallax is ignored 10 offset: 0, 11 axis: "y", 12 breakpoint: 990 13 }, options); 14 15 var isX = (settings.axis == "x"); 16 17 var $that = $(this); 18 19 var visibleAt = $that.offset().top - $(window).height(); 20 if (visibleAt < 0) { 21 visibleAt = 0; 22 } 23 24 var currentVal = 0; 25 var destinationVal = 0; 26 27 var reposition = function () { 28 29 var width = $(window).width(); 30 if (window.matchMedia("(min-width: " + settings.breakpoint + "px)").matches) { 31 var wtop = $(window).scrollTop(); 32 if (wtop >= visibleAt) { 33 34 var seeing = wtop - visibleAt; 35 var val = seeing * (1 - settings.speed); 36 destinationVal = val - settings.offset; 37 } 38 } else { 39 $that.css("transform", ""); 40 } 41 }; 42 43 44 var redraw = function () { 45 var diff = currentVal - destinationVal; 46 if (diff > 1 || diff < -1) { 47 currentVal -= diff / 12; 48 49 if (isX) { 50 $that[0].style.transform = "translate3d(" + (currentVal) + "px, 0, 0)"; 51 } else { 52 $that[0].style.transform = "translate3d(0, " + (-currentVal) + "px, 0)"; 53 } 54 } else { 55 if (currentVal != destinationVal) { 56 if (isX) { 57 $that[0].style.transform = "translate3d(" + (destinationVal) + "px, 0, 0)"; 58 } else { 59 $that[0].style.transform = "translate3d(0, " + (-destinationVal) + "px, 0)"; 60 } 61 currentVal = destinationVal; 62 $(window).trigger("scroll"); 63 } 64 } 65 66 window.requestAnimationFrame(redraw); 67 }; 68 69 70 window.requestAnimationFrame(redraw); 71 72 setTimeout(reposition, 1); 73 $(window).on("scroll resize", reposition); 74 reposition(); 75 }); 76 }; 77}(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.