Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit a28abdd

Browse files
authored
Merge pull request #6 from ryuran/fix/20minutes/offsetTop
remove log and add a disable behavior if height too big
2 parents 48c905e + e796d98 commit a28abdd

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stickymadness",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "",
55
"main": "src/sticky.js",
66
"scripts": {

src/sticky.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@
191191
// only calcul position relative to vewport
192192
this.updatePosition();
193193

194-
console.log(this.position, this.offsetTop);
195-
196-
console.log('limit : ', this.limitTop, this.limitBottom);
194+
if(this.el.offsetHeight >= (this.limitBottom - this.limitTop)) {
195+
this.disable();
196+
return;
197+
}
197198

198199
// ON STICK
199200
if (!this.isSticked && this.position.offsetTop < this.offsetTop) {
@@ -210,13 +211,13 @@
210211
}
211212

212213
// ON STUCK
213-
if (!this.isStucked && this.position.bottom >= this.limitBottom) {
214+
if (!this.isStucked && this.position.bottom > this.limitBottom) {
214215
this.el.classList.add(this.options.stuckClass);
215216
this.options.onStuck(this.el);
216217
}
217218

218219
// ON DESTUCK
219-
if (this.isStucked && this.position.offsetTop >= this.offsetTop) {
220+
if (this.isStucked && this.position.offsetTop > this.offsetTop) {
220221
this.el.classList.remove(this.options.stuckClass);
221222
this.options.onUnStuck(this.el);
222223
}

0 commit comments

Comments
 (0)