', stuckClass: 'stuck' }; wrap = function($elements, options) { $elements.wrap(options.wrapper); $elements.each(function() { var $this; $this = $(this); $this.parent().height($this.outerHeight()); return true; }); return $elements.parent(); }; return $.waypoints('extendFn', 'sticky', function(options) { var $wrap, originalHandler; options = $.extend({}, $.fn.waypoint.defaults, defaults, options); $wrap = wrap(this, options); originalHandler = options.handler; options.handler = function(direction) { var $sticky, shouldBeStuck; $sticky = $(this).children(':first'); shouldBeStuck = direction === 'down' || direction === 'right'; $sticky.toggleClass(options.stuckClass, shouldBeStuck); if (originalHandler != null) { return originalHandler.call(this, direction); } }; $(document).on("navChange", $.proxy(function(){ $.waypoints("refresh"); }, this)); $wrap.waypoint(options); return this; }); }); }).call(this);