Skip to content

Commit

Permalink
Project build
Browse files Browse the repository at this point in the history
  • Loading branch information
skhilko committed Apr 19, 2015
1 parent d74d96c commit ab21a8f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/maps/stickyheaders.jquery.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/maps/stickyheaders.min.js.map

Large diffs are not rendered by default.

49 changes: 39 additions & 10 deletions dist/scripts/stickyheaders.jquery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
;(function($, window, document, undefined) {/* global WheelEvent */
;(function($, document, undefined) {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.StickyHeaders = factory();
}
}(this, function() {
/* global WheelEvent */
'use strict';

var SCROLL_WIDTH = (function() {
Expand Down Expand Up @@ -36,6 +46,7 @@ function StickyHeaders(el, options) {
this.options = options;
this.stuckHeadersHeight = 0;
this._updating = false;
this._events = [];

this._readListStyles();

Expand All @@ -61,7 +72,7 @@ function StickyHeaders(el, options) {

this._createHeaderContainer();

el.addEventListener('scroll', this.onScroll.bind(this));
this._on('scroll', this.onScroll);
}

StickyHeaders.prototype._readListStyles = function() {
Expand All @@ -75,7 +86,7 @@ StickyHeaders.prototype._readListStyles = function() {
};

StickyHeaders.prototype._createHeaderContainer = function() {
var header = document.createElement('div');
var header = this.header = document.createElement('div');
header.className = 'sticky-container';

var headerWrap = document.createElement('div');
Expand Down Expand Up @@ -167,12 +178,27 @@ StickyHeaders.prototype.onHeaderScroll = function(ev) {
ev.preventDefault();
};

StickyHeaders.prototype._on = function(event, handler) {
handler = handler.bind(this);
this.element.addEventListener(event, handler);
this._events.push({
el: this.element,
ev: event,
handler: handler
});
};

StickyHeaders.prototype.destroy = function() {
this._events.forEach(function(eventData) {
eventData.el.removeEventListener(eventData.ev, eventData.handler);
});
this.element.parentNode.removeChild(this.header);
};

StickyHeaders.prototype.isWithinHeaderContainer = function(header, scrollTop) {
return header.top >= scrollTop && header.top <= this.headerContainerHeight + scrollTop;
};

window.StickyHeaders = StickyHeaders;

var pluginName = 'stickyHeaders';

function Plugin(element, options) {
Expand All @@ -182,11 +208,11 @@ function Plugin(element, options) {
}

Plugin.prototype.init = function() {
this.akno = new StickyHeaders(this.element, this.options);
this.widget = new StickyHeaders(this.element, this.options);
};

Plugin.prototype.destroy = function() {
this.akno.destroy();
this.widget.destroy();
$.removeData(this.element, 'plugin_' + pluginName);
this.element = null;
};
Expand All @@ -205,12 +231,15 @@ $.fn[pluginName] = function(options) {
var instance = $.data(this, dataKey);
if (instance instanceof Plugin) {
// call with the widget instance if not on the plugin
if(!$.isFunction(instance[options]) && $.isFunction(instance.akno[options])) {
instance = instance.akno;
if(!$.isFunction(instance[options]) && $.isFunction(instance.widget[options])) {
instance = instance.widget;
}
instance[options].apply(instance, Array.prototype.slice.call(args, 1));
}
});
}
};
})(jQuery, window, window.document);

return StickyHeaders;
}));
})(jQuery, window.document);
2 changes: 1 addition & 1 deletion dist/scripts/stickyheaders.jquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 34 additions & 5 deletions dist/scripts/stickyheaders.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
;(function(window, document, undefined) {/* global WheelEvent */
;(function(document, undefined) {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.StickyHeaders = factory();
}
}(this, function() {
/* global WheelEvent */
'use strict';

var SCROLL_WIDTH = (function() {
Expand Down Expand Up @@ -36,6 +46,7 @@ function StickyHeaders(el, options) {
this.options = options;
this.stuckHeadersHeight = 0;
this._updating = false;
this._events = [];

this._readListStyles();

Expand All @@ -61,7 +72,7 @@ function StickyHeaders(el, options) {

this._createHeaderContainer();

el.addEventListener('scroll', this.onScroll.bind(this));
this._on('scroll', this.onScroll);
}

StickyHeaders.prototype._readListStyles = function() {
Expand All @@ -75,7 +86,7 @@ StickyHeaders.prototype._readListStyles = function() {
};

StickyHeaders.prototype._createHeaderContainer = function() {
var header = document.createElement('div');
var header = this.header = document.createElement('div');
header.className = 'sticky-container';

var headerWrap = document.createElement('div');
Expand Down Expand Up @@ -167,9 +178,27 @@ StickyHeaders.prototype.onHeaderScroll = function(ev) {
ev.preventDefault();
};

StickyHeaders.prototype._on = function(event, handler) {
handler = handler.bind(this);
this.element.addEventListener(event, handler);
this._events.push({
el: this.element,
ev: event,
handler: handler
});
};

StickyHeaders.prototype.destroy = function() {
this._events.forEach(function(eventData) {
eventData.el.removeEventListener(eventData.ev, eventData.handler);
});
this.element.parentNode.removeChild(this.header);
};

StickyHeaders.prototype.isWithinHeaderContainer = function(header, scrollTop) {
return header.top >= scrollTop && header.top <= this.headerContainerHeight + scrollTop;
};

window.StickyHeaders = StickyHeaders;
})(window, window.document);
return StickyHeaders;
}));
})(window.document);
2 changes: 1 addition & 1 deletion dist/scripts/stickyheaders.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ab21a8f

Please sign in to comment.