From 7f1df08af68de9d993ab695ab470add3b8df2647 Mon Sep 17 00:00:00 2001 From: Yvain Liechti Date: Tue, 11 Apr 2017 21:17:48 +0200 Subject: [PATCH] change parametter for callback function --- package.json | 2 +- src/sticky.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2493564..a3a82e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stickymadness", - "version": "0.1.1", + "version": "0.1.2", "description": "", "main": "src/sticky.js", "scripts": { diff --git a/src/sticky.js b/src/sticky.js index 0b2d1e7..f020c62 100644 --- a/src/sticky.js +++ b/src/sticky.js @@ -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 @@ -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;