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

Commit 74113c2

Browse files
author
rgalus
committed
1.1.9
1 parent 87ee9c2 commit 74113c2

6 files changed

+45
-7
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
"test",
1919
"tests"
2020
],
21-
"version": "1.1.8"
21+
"version": "1.1.9"
2222
}

dist/sticky.compile.js

+40-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
44
* Sticky.js
55
* Library for sticky elements written in vanilla javascript. With this library you can easily set sticky elements on your website. It's also responsive.
66
*
7-
* @version 1.1.8
7+
* @version 1.1.9
88
* @author Rafal Galus <[email protected]>
99
* @website https://rgalus.github.io/sticky-js/
1010
* @repo https://github.com/rgalus/sticky-js
@@ -27,7 +27,7 @@ var Sticky = function () {
2727
this.selector = selector;
2828
this.elements = [];
2929

30-
this.version = '1.1.8';
30+
this.version = '1.1.9';
3131

3232
this.vp = this.getViewportSize();
3333
this.scrollTop = this.getScrollTopPosition();
@@ -167,6 +167,17 @@ var Sticky = function () {
167167
window.addEventListener('resize', element.sticky.resizeListener);
168168
};
169169

170+
/**
171+
* Removes element listener from resize event
172+
* @function
173+
* @param {node} element - Element from which listener is deleted
174+
*/
175+
176+
177+
Sticky.prototype.destroyResizeEvents = function destroyResizeEvents(element) {
178+
window.removeEventListener('resize', element.sticky.resizeListener);
179+
};
180+
170181
/**
171182
* Function which is fired when user resize window. It checks if element should be activated or deactivated and then run setPosition function
172183
* @function
@@ -205,6 +216,17 @@ var Sticky = function () {
205216
window.addEventListener('scroll', element.sticky.scrollListener);
206217
};
207218

219+
/**
220+
* Removes element listener from scroll event
221+
* @function
222+
* @param {node} element - Element from which listener is deleted
223+
*/
224+
225+
226+
Sticky.prototype.destroyScrollEvents = function destroyScrollEvents(element) {
227+
window.removeEventListener('scroll', element.sticky.scrollListener);
228+
};
229+
208230
/**
209231
* Function which is fired when user scroll window. If element is active, function is invoking setPosition function
210232
* @function
@@ -306,6 +328,22 @@ var Sticky = function () {
306328
});
307329
};
308330

331+
/**
332+
* Destroys sticky element, remove listeners
333+
* @function
334+
*/
335+
336+
337+
Sticky.prototype.destroy = function destroy() {
338+
var _this6 = this;
339+
340+
this.forEach(this.elements, function (element) {
341+
_this6.destroyResizeEvents(element);
342+
_this6.destroyScrollEvents(element);
343+
delete element.sticky;
344+
});
345+
};
346+
309347
/**
310348
* Function that returns container element in which sticky element is stuck (if is not specified, then it's stuck to body)
311349
* @function

dist/sticky.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sticky.min.js.gz

47 Bytes
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sticky-js",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"description": "Sticky elements",
55
"main": "index.js",
66
"scripts": {

src/sticky.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Sticky.js
44
* Library for sticky elements written in vanilla javascript. With this library you can easily set sticky elements on your website. It's also responsive.
55
*
6-
* @version 1.1.8
6+
* @version 1.1.9
77
* @author Rafal Galus <[email protected]>
88
* @website https://rgalus.github.io/sticky-js/
99
* @repo https://github.com/rgalus/sticky-js
@@ -21,7 +21,7 @@ class Sticky {
2121
this.selector = selector;
2222
this.elements = [];
2323

24-
this.version = '1.1.8';
24+
this.version = '1.1.9';
2525

2626
this.vp = this.getViewportSize();
2727
this.scrollTop = this.getScrollTopPosition();

0 commit comments

Comments
 (0)