Skip to content

Commit

Permalink
Merge pull request #8 from ryuran/fix/20minutes/offsetTop
Browse files Browse the repository at this point in the history
change parammetter for callback function
  • Loading branch information
ryuran authored Apr 11, 2017
2 parents 7a00d1a + 7f1df08 commit bd1e743
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stickymadness",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "src/sticky.js",
"scripts": {
Expand Down
22 changes: 11 additions & 11 deletions src/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
},

// callbacks
onInit: function(){}, // (element)
onEnabling: function(){}, // (element)
onDisabling: function(){}, // (element)
onStick: function(){}, // (element)
onUnStick: function(){}, // (element)
onStuck: function(){}, // (element)
onUnStuck: function(){} // (element)
onInit: function () {}, // (stickyObject)
onEnabling: function () {}, // (stickyObject)
onDisabling: function () {}, // (stickyObject)
onStick: function () {}, // (stickyObject)
onUnStick: function () {}, // (stickyObject)
onStuck: function () {}, // (stickyObject)
onUnStuck: function () {} // (stickyObject)
};

// utils
Expand Down Expand Up @@ -202,27 +202,27 @@
// ON STICK
if (!this.isSticked && this.position.offsetTop < this.offsetTop) {
this.el.classList.add(this.options.stickClass);
this.options.onStick(this.el);
this.options.onStick(this);
this.el.style.top = this.offsetTop + 'px';
}

// ON DESTICK
if (this.isSticked && this.position.top <= this.limitTop) {
this.el.classList.remove(this.options.stickClass);
this.options.onUnStick(this.el);
this.options.onUnStick(this);
this.el.style.removeProperty('top');
}

// ON STUCK
if (!this.isStucked && this.position.bottom > this.limitBottom) {
this.el.classList.add(this.options.stuckClass);
this.options.onStuck(this.el);
this.options.onStuck(this);
}

// ON DESTUCK
if (this.isStucked && this.position.offsetTop > this.offsetTop) {
this.el.classList.remove(this.options.stuckClass);
this.options.onUnStuck(this.el);
this.options.onUnStuck(this);
}

this.ticking = false;
Expand Down

0 comments on commit bd1e743

Please sign in to comment.