aw-front-helpers 3.0.3 → 3.0.5

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 CHANGED
@@ -69,15 +69,11 @@ export default class Sticky extends EventEmitter {
69
69
  this._options.topHeightAdjustement;
70
70
  const stickyFilter = positionSticky < 0;
71
71
 
72
- const stickyBottomWrapperPage =
73
- this._vars.scrollY + this._vars.height >
74
- this._cache.wrapperTop + this._cache.wrapperHeight;
75
- const stickyBottomElement =
72
+ const stickyEndFilter =
76
73
  this._vars.scrollY +
77
74
  this._options.topHeightAdjustement +
78
75
  this._cache.containerHeight >
79
76
  this._cache.wrapperTop + this._cache.wrapperHeight;
80
- const stickyEndFilter = stickyBottomWrapperPage && stickyBottomElement;
81
77
  if (this._cache.wrapperHeight < this._cache.containerHeight) {
82
78
  this._dom.el.classList.remove('is-sticky', 'is-sticky-end');
83
79
  return;
@@ -100,18 +96,24 @@ export default class Sticky extends EventEmitter {
100
96
  }
101
97
  if (stickyEndFilter && !this._isEndSticky) {
102
98
  this._isEndSticky = true;
99
+ this._isSticky = false;
103
100
  this._dom.el.style.top = null;
104
101
  this._dom.el.style.width = null;
102
+ this._dom.el.classList.remove('is-sticky');
105
103
  this._dom.el.classList.add('is-sticky-end');
106
104
  document.body.dispatchEvent(this._eventEndChange);
105
+ if(this._callbackLeave) this._callbackLeave();
107
106
  if(this._callbackEnterEnd) this._callbackEnterEnd();
108
107
  } else if (!stickyEndFilter && this._isEndSticky) {
109
108
  this._isEndSticky = false;
109
+ this._isSticky = true;
110
110
  this._dom.el.style.top = `${this._options.topHeightAdjustement}px`;
111
111
  this._dom.el.style.width = `${this._cache.containerWidth}px`;
112
112
  this._dom.el.classList.remove('is-sticky-end');
113
+ this._dom.el.classList.add('is-sticky');
113
114
  document.body.dispatchEvent(this._eventEndChange);
114
115
  if(this._callbackLeaveEnd) this._callbackLeaveEnd();
116
+ if(this._callbackEnter) this._callbackEnter();
115
117
  }
116
118
  }
117
119
 
@@ -126,6 +128,7 @@ export default class Sticky extends EventEmitter {
126
128
  this._isSticky = false;
127
129
  this._isEndSticky = false;
128
130
  this._dom.el.classList.remove('is-sticky', 'is-sticky-end');
131
+ this._dom.el.style.top = null;
129
132
  this._dom.el.style.width = null;
130
133
  setTimeout(() => {
131
134
  const boudingWrapper = this._dom.wrapper.getBoundingClientRect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",
@@ -1,4 +1,5 @@
1
1
  @use './medias' as *;
2
+ @use './functions' as *;
2
3
 
3
4
  // ------------------------------------------------------------
4
5
  // MIXINS
@@ -1,3 +1,5 @@
1
+ @use './functions' as *;
2
+
1
3
  html,
2
4
  body,
3
5
  div,