Skip to content

Commit

Permalink
Fixes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
markgoodyear committed Jun 8, 2015
1 parent 2ecde05 commit 2fa3e6d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
27 changes: 16 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Headhesive changelog

## v1.2.4
- Fix resize event when using numerical offset
- Fix destroy method for resize event
- Changelog corrections

## v1.2.3
- [Fix] Readme correction
- Readme correction

## v1.2.2
- [Fix] Fix UMD support
- Fix UMD support

## v1.2.1
- [Fix] Bump version to publish to npm
- Bump version to publish to npm

## v1.2.0
- [Feature] Add UMD support
- [Feature] Allow to select either the top or bottom of the offset element
- [Feature] Update the offset position on browser resize
- Add UMD support
- Allow to select either the top or bottom of the offset element
- Update the offset position on browser resize
- Publish to npm
- Add license file
- [Fix] Make the clone version lower z-index than original. Prevents visual overlap of both when scrolling quickly
- Make the clone version lower z-index than original. Prevents visual overlap of both when scrolling quickly

## v1.1.1
- [Fix] Fix class naming
- Fix class naming

## v1.1.0
- [Feature] Call the init method interally on instance creation
- [Fix] Destroy method to only destroy it's instance
- Call the init method internally on instance creation
- Destroy method to only destroy it's instance

## v1.0.0
- Inital
- Initial
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Headhesive.js",
"version": "1.2.3",
"version": "1.2.4",
"homepage": "http://markgoodyear.com/labs/headhesive/",
"authors": [
"Mark Goodyear <[email protected]> (http://markgoodyear.com)"
Expand Down
8 changes: 5 additions & 3 deletions dist/headhesive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Headhesive.js v1.2.1 - An on-demand sticky header
* Headhesive.js v1.2.3 - An on-demand sticky header
* Author: Copyright (c) Mark Goodyear <@markgdyr> <http://markgoodyear.com>
* Url: http://markgoodyear.com/labs/headhesive
* License: MIT
Expand Down Expand Up @@ -112,12 +112,14 @@
this.options.onInit.call(this);
},
_setScrollOffset: function() {
this.scrollOffset = _getElemY(document.querySelector(this.options.offset), this.options.offsetSide);
if (typeof this.options.offset === "string") {
this.scrollOffset = _getElemY(document.querySelector(this.options.offset), this.options.offsetSide);
}
},
destroy: function() {
document.body.removeChild(this.clonedElem);
window.removeEventListener("scroll", this._throttleUpdate);
window.removeEventListener("scroll", this._throttleScrollOffset);
window.removeEventListener("resize", this._throttleScrollOffset);
this.options.onDestroy.call(this);
},
stick: function() {
Expand Down
4 changes: 2 additions & 2 deletions dist/headhesive.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "headhesive",
"description": "An on-demand sticky header",
"version": "1.2.3",
"version": "1.2.4",
"author": {
"name": "Mark Goodyear",
"url": "http://markgoodyear.com",
Expand Down
15 changes: 12 additions & 3 deletions src/headhesive.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,21 @@
this._throttleUpdate = _throttle(this.update.bind(this), this.options.throttle);
this._throttleScrollOffset = _throttle(this._setScrollOffset.bind(this), this.options.throttle);

// Events
// Events.
window.addEventListener('scroll', this._throttleUpdate, false);
window.addEventListener('resize', this._throttleScrollOffset, false);

// Callback.
this.options.onInit.call(this);
},

/**
* Sets the scrollOffset value.
*/
_setScrollOffset: function () {
this.scrollOffset = _getElemY(document.querySelector(this.options.offset), this.options.offsetSide);
if (typeof this.options.offset === 'string') {
this.scrollOffset = _getElemY(document.querySelector(this.options.offset), this.options.offsetSide);
}
},

/**
Expand All @@ -105,7 +108,9 @@
destroy: function () {
document.body.removeChild(this.clonedElem);
window.removeEventListener('scroll', this._throttleUpdate);
window.removeEventListener('scroll', this._throttleScrollOffset);
window.removeEventListener('resize', this._throttleScrollOffset);

// Callback.
this.options.onDestroy.call(this);
},

Expand All @@ -117,6 +122,8 @@
this.clonedElem.className = this.clonedElem.className.replace(new RegExp('(^|\\s)*' + this.options.classes.unstick + '(\\s|$)*', 'g'), '');
this.clonedElem.className += ' ' + this.options.classes.stick;
this.visible = true;

// Callback.
this.options.onStick.call(this);
}
},
Expand All @@ -129,6 +136,8 @@
this.clonedElem.className = this.clonedElem.className.replace(new RegExp('(^|\\s)*' + this.options.classes.stick + '(\\s|$)*', 'g'), '');
this.clonedElem.className += ' ' + this.options.classes.unstick;
this.visible = false;

// Callback.
this.options.onUnstick.call(this);
}
},
Expand Down

0 comments on commit 2fa3e6d

Please sign in to comment.