Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
themes
/
indutri
/
js
:
sticky.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
(function ($) { 'use strict' var $ = window.jQuery var Waypoint = window.Waypoint function Sticky(options) { this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options) this.element = this.options.element this.$element = $(this.element) this.createWrapper() this.createWaypoint() } 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), offset: 0 })) } Sticky.prototype.createWrapper = function() { if (this.options.wrapper) { this.$element.wrap(this.options.wrapper) } this.$wrapper = this.$element.parent() this.wrapper = this.$wrapper[0] } Sticky.prototype.destroy = function() { if (this.$element.parent()[0] === this.wrapper) { this.waypoint.destroy() this.$element.removeClass(this.options.stuckClass) if (this.options.wrapper) { this.$element.unwrap() } } } $(document).ready(function(){ Sticky.defaults = { wrapper: '<div class="sticky-wrapper" />', stuckClass: 'stuck', direction: 'down right' } Waypoint.Sticky = Sticky }); })(jQuery);