Sha256: 2b6760b7736e475ba1ae794f800731628a3d0a20818e46319639e3dc0a9cd057
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
/*! Waypoints Sticky Element Shortcut - 3.0.0 Copyright © 2011-2014 Caleb Troughton Licensed under the MIT license. https://github.com/imakewebthings/waypoints/blog/master/licenses.txt */ (function() { 'use strict' var $ = window.jQuery var Waypoint = window.Waypoint /* http://imakewebthings.com/waypoints/shortcuts/sticky-elements */ function Sticky(options) { this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options) this.element = this.options.element this.$element = $(this.element) this.createWrapper() this.createWaypoint() } /* Private */ Sticky.prototype.createWaypoint = function() { var originalHandler = this.options.handler this.waypoint = new Waypoint($.extend({}, this.options, { element: this.wrapper, handler: $.proxy(function(direction) { var shouldBeStuck = this.options.direction.indexOf(direction) > -1 var wrapperHeight = shouldBeStuck ? this.$element.outerHeight(true) : '' this.$wrapper.height(wrapperHeight) this.$element.toggleClass(this.options.stuckClass, shouldBeStuck) if (originalHandler) { originalHandler.call(this, direction) } }, this) })) } /* Private */ Sticky.prototype.createWrapper = function() { this.$element.wrap(this.options.wrapper) this.$wrapper = this.$element.parent() this.wrapper = this.$wrapper[0] } /* Public */ Sticky.prototype.destroy = function() { if (this.$element.parent()[0] === this.wrapper) { this.waypoint.destroy() this.$element.removeClass(this.options.stuckClass).unwrap() } } Sticky.defaults = { wrapper: '<div class="sticky-wrapper" />', stuckClass: 'stuck', direction: 'down right' } Waypoint.Sticky = Sticky }()) ;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
assets-rails-0.2.0 | app/assets/javascripts/waypoints/v3.0.1/shortcuts/sticky.js |