aw-front-helpers 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/classes/sticky.js +20 -14
- package/package.json +1 -1
package/classes/sticky.js
CHANGED
|
@@ -30,12 +30,12 @@ export default class Sticky extends EventEmitter {
|
|
|
30
30
|
return this._options;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
set breakpointDisabled(
|
|
33
|
+
set breakpointDisabled(breakpoint) {
|
|
34
34
|
this._options.breakpointDisabled = breakpoint;
|
|
35
35
|
this.update();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
set topHeightAdjustement(
|
|
38
|
+
set topHeightAdjustement(height) {
|
|
39
39
|
this._options.topHeightAdjustement = height;
|
|
40
40
|
this.update();
|
|
41
41
|
}
|
|
@@ -99,20 +99,9 @@ export default class Sticky extends EventEmitter {
|
|
|
99
99
|
|
|
100
100
|
_onResize() {
|
|
101
101
|
if (this._options.breakpointDisabled && window.innerWidth < this._options.breakpointDisabled) {
|
|
102
|
-
|
|
103
|
-
this._isDisabled = true;
|
|
104
|
-
this._dom.el.classList.remove("is-sticky", "is-sticky-end");
|
|
105
|
-
this._dom.el.style.top = null;
|
|
106
|
-
this._dom.el.style.width = null;
|
|
107
|
-
this.emit('disable');
|
|
108
|
-
}
|
|
102
|
+
this._setDisabled();
|
|
109
103
|
return;
|
|
110
104
|
}
|
|
111
|
-
if (this._isDisabled) {
|
|
112
|
-
this._isDisabled = false;
|
|
113
|
-
this.emit('enable');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
105
|
this._isSticky = false;
|
|
117
106
|
this._isEndSticky = false;
|
|
118
107
|
this._dom.el.classList.remove("is-sticky", "is-sticky-end");
|
|
@@ -132,6 +121,14 @@ export default class Sticky extends EventEmitter {
|
|
|
132
121
|
wrapperTop: boudingWrapper.top + this._vars.scrollY,
|
|
133
122
|
wrapperHeight: boudingWrapper.height,
|
|
134
123
|
};
|
|
124
|
+
if (boudingWrapper.height <= boudingContainer.height) {
|
|
125
|
+
this._setDisabled();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this._isDisabled) {
|
|
129
|
+
this._isDisabled = false;
|
|
130
|
+
this.emit('enable');
|
|
131
|
+
}
|
|
135
132
|
this._onScrollHandler();
|
|
136
133
|
});
|
|
137
134
|
}
|
|
@@ -141,6 +138,15 @@ export default class Sticky extends EventEmitter {
|
|
|
141
138
|
["_onScroll", "_onScrollHandler", "_onResize"].forEach((fn) => (this[fn] = this[fn].bind(this)));
|
|
142
139
|
}
|
|
143
140
|
|
|
141
|
+
_setDisabled() {
|
|
142
|
+
if (this._isDisabled) return;
|
|
143
|
+
this._isDisabled = true;
|
|
144
|
+
this._dom.el.classList.remove("is-sticky", "is-sticky-end");
|
|
145
|
+
this._dom.el.style.top = null;
|
|
146
|
+
this._dom.el.style.width = null;
|
|
147
|
+
this.emit('disable');
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
_grabDom() {
|
|
145
151
|
this._dom = {};
|
|
146
152
|
this._dom.el = this._options.el.querySelector("[data-sticker-element]");
|