diff --git a/ajax/libs/jquery.pin/0.1/jquery.pin.js b/ajax/libs/jquery.pin/0.1/jquery.pin.js new file mode 100644 index 00000000000000..180452b9100101 --- /dev/null +++ b/ajax/libs/jquery.pin/0.1/jquery.pin.js @@ -0,0 +1,95 @@ +(function ($) { + "use strict"; + $.fn.pin = function (options) { + var scrollY = 0, elements = [], disabled = false, $window = $(window); + + options = options || {}; + + var recalculateLimits = function () { + for (var i=0, len=elements.length; i"); + } + + $this.data("pin", { + from: options.containerSelector ? containerOffset.top : offset.top, + to: containerOffset.top + $container.height() - $this.outerHeight(), + end: containerOffset.top + $container.height(), + parentTop: parentOffset.top + }); + + $this.css({width: $this.outerWidth()}); + $this.parent().css("height", $this.outerHeight()); + } + }; + + var onScroll = function () { + if (disabled) { return; } + + scrollY = $window.scrollTop(); + + for (var i=0, len=elements.length; i data.end) { + $this.css('position', ''); + continue; + } + + if (from < scrollY && to > scrollY) { + !($this.css("position") == "fixed") && $this.css({ + left: $this.offset().left, + top: 0 + }).css("position", "fixed"); + } else if (scrollY >= to) { + $this.css({ + left: "auto", + top: to - data.parentTop + }).css("position", "absolute"); + } else { + $this.css({position: "", top: "", left: ""}); + } + } + }; + + var update = function () { recalculateLimits(); onScroll(); }; + + this.each(function () { + var $this = $(this), + data = $(this).data('pin') || {}; + + if (data && data.update) { return; } + elements.push($this); + $("img", this).one("load", recalculateLimits); + data.update = update; + $(this).data('pin', data); + }); + + $window.scroll(onScroll); + $window.resize(function () { recalculateLimits(); }); + recalculateLimits(); + + $window.load(update); + + return this; + }; +})(jQuery); \ No newline at end of file diff --git a/ajax/libs/jquery.pin/0.1/jquery.pin.min.js b/ajax/libs/jquery.pin/0.1/jquery.pin.min.js new file mode 100644 index 00000000000000..efc9dd112dc96d --- /dev/null +++ b/ajax/libs/jquery.pin/0.1/jquery.pin.min.js @@ -0,0 +1 @@ +(function(e){"use strict";e.fn.pin=function(t){var n=0,r=[],i=!1;t=t||{};var s=function(){for(var n=0,s=r.length;n"),o.data("pin",{from:t.containerSelector?f.top:a.top,to:f.top+u.height()-o.outerHeight(),end:f.top+u.height(),parentTop:l.top}),o.css({width:o.outerWidth()}),o.parent().css("height",o.outerHeight())}},o=function(){if(i)return;n=window.scrollY;for(var t=0,s=r.length;tu.end){o.css("position","");continue}an?o.css("position")!="fixed"&&o.css({left:o.offset().left,top:0}).css("position","fixed"):n>=f?o.css({left:"auto",top:f-u.parentTop}).css("position","absolute"):o.css({position:"",top:"",left:""})}},u=function(){s(),o()};return this.each(function(){var t=e(this),n=e(this).data("pin")||{};if(n&&n.update)return;r.push(t),e("img",this).one("load",s),n.update=u,e(this).data("pin",n)}),e(window).scroll(o),e(window).resize(function(){s()}),s(),e(window).load(u),this}})(jQuery); \ No newline at end of file diff --git a/ajax/libs/jquery.pin/package.json b/ajax/libs/jquery.pin/package.json new file mode 100644 index 00000000000000..7c45e393655dfe --- /dev/null +++ b/ajax/libs/jquery.pin/package.json @@ -0,0 +1,35 @@ +{ + "name": "jquery.pin", + "filename": "jquery.pin.min.js", + "description": "Pin any element within a container", + "version": "0.1", + "keywords": [ + "jquery-pin", + "jquery.pin", + "pin" + ], + "maintainers": [ + { + "name": "Mathias Biilmann", + "email": "us@webpop.com", + "web": "https://github.com/webpop" + } + ], + "demos": [ + "http://webpop.github.com/jquery.pin/" + ], + "bugs": "https://github.com/webpop/jquery.pin/issues", + "repositories": [ + { + "type": "git", + "url": "https://github.com/webpop/jquery.pin.git" + } + ], + "licenses": [ + { + "name": "Personalized License", + "url": "https://github.com/webpop/jquery.pin#license" + } + ], + "homepage": "http://webpop.github.com/jquery.pin/" +} \ No newline at end of file