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

Commit 91bc585

Browse files
author
rgalus
committed
1.1.6
1 parent 720428d commit 91bc585

6 files changed

+15
-11
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.5"
21+
"version": "1.1.6"
2222
}

dist/sticky.compile.js

+10-6
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.5
7+
* @version 1.1.6
88
* @author Rafal Galus <[email protected]>
99
* @website https://rgalus.github.io/sticky-js/
1010
* @repo https://github.com/rgalus/sticky-js
@@ -27,16 +27,17 @@ var Sticky = function () {
2727
this.selector = selector;
2828
this.elements = [];
2929

30-
this.version = '1.1.5';
30+
this.version = '1.1.6';
3131

3232
this.vp = this.getViewportSize();
3333
this.scrollTop = this.getScrollTopPosition();
34+
this.body = document.querySelector('body');
3435

3536
this.options = {
3637
marginTop: options.marginTop || 0,
3738
stickyFor: options.stickFor || 0,
3839
stickyClass: options.stickyClass || null,
39-
stickyContainer: options.stickContainer || 'body'
40+
stickyContainer: options.stickyContainer || 'body'
4041
};
4142

4243
this.run();
@@ -83,6 +84,9 @@ var Sticky = function () {
8384
element.sticky.marginTop = parseInt(element.getAttribute('data-margin-top')) || this.options.marginTop;
8485
element.sticky.stickyFor = parseInt(element.getAttribute('data-sticky-for')) || this.options.stickyFor;
8586
element.sticky.stickyClass = element.getAttribute('data-sticky-class') || this.options.stickyClass;
87+
// @todo attribute for stickyContainer
88+
// element.sticky.stickyContainer = element.getAttribute('data-sticky-container') || this.options.stickyContainer;
89+
element.sticky.stickyContainer = this.options.stickyContainer;
8690

8791
element.sticky.container = this.getStickyContainer(element);
8892
element.sticky.container.rect = this.getRectangle(element.sticky.container);
@@ -216,7 +220,7 @@ var Sticky = function () {
216220
element.sticky.rect = this.getRectangle(element);
217221
}
218222

219-
if (element.sticky.rect.top === 0 && element.sticky.container === document.querySelector('body')) {
223+
if (element.sticky.rect.top === 0 && element.sticky.container === this.body) {
220224
this.css(element, {
221225
position: 'fixed',
222226
top: element.sticky.rect.top + 'px',
@@ -275,9 +279,9 @@ var Sticky = function () {
275279

276280

277281
Sticky.prototype.getStickyContainer = function getStickyContainer(element) {
278-
var container = element;
282+
var container = element.parentNode;
279283

280-
while (!container.hasAttribute('data-sticky-container') && !container.parentNode.querySelector(this.options.stickyContainer) && container !== document.querySelector('body')) {
284+
while (!container.hasAttribute('data-sticky-container') && !container.parentNode.querySelector(element.sticky.stickyContainer) && container !== this.body) {
281285
container = container.parentNode;
282286
}
283287

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

14 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.5",
3+
"version": "1.1.6",
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.5
6+
* @version 1.1.6
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.5';
24+
this.version = '1.1.6';
2525

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

0 commit comments

Comments
 (0)