aw-front-helpers 3.0.1 → 3.0.2

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.
Files changed (2) hide show
  1. package/classes/sticky.js +10 -1
  2. package/package.json +1 -1
package/classes/sticky.js CHANGED
@@ -12,7 +12,8 @@ export default class Sticky extends EventEmitter {
12
12
  topHeightAdjustement: 0,
13
13
  ...options,
14
14
  };
15
-
15
+ this._eventChange = new CustomEvent('sticky::update');
16
+ this._eventEndChange = new CustomEvent('sticky::updateEnd');
16
17
  this._isDisabled = false;
17
18
  this._isSticky = false;
18
19
  this._isEndSticky = false;
@@ -87,22 +88,30 @@ export default class Sticky extends EventEmitter {
87
88
  this._dom.el.classList.add('is-sticky');
88
89
  this._dom.el.style.top = `${this._options.topHeightAdjustement}px`;
89
90
  this._dom.el.style.width = `${this._cache.containerWidth}px`;
91
+ document.body.dispatchEvent(this._eventChange);
92
+ if(this._callbackEnter) this._callbackEnter();
90
93
  } else if (!stickyFilter && this._isSticky) {
91
94
  this._isSticky = false;
92
95
  this._dom.el.style.top = null;
93
96
  this._dom.el.style.width = null;
94
97
  this._dom.el.classList.remove('is-sticky');
98
+ document.body.dispatchEvent(this._eventChange);
99
+ if(this._callbackLeave) this._callbackLeave();
95
100
  }
96
101
  if (stickyEndFilter && !this._isEndSticky) {
97
102
  this._isEndSticky = true;
98
103
  this._dom.el.style.top = null;
99
104
  this._dom.el.style.width = null;
100
105
  this._dom.el.classList.add('is-sticky-end');
106
+ document.body.dispatchEvent(this._eventEndChange);
107
+ if(this._callbackEnterEnd) this._callbackEnterEnd();
101
108
  } else if (!stickyEndFilter && this._isEndSticky) {
102
109
  this._isEndSticky = false;
103
110
  this._dom.el.style.top = `${this._options.topHeightAdjustement}px`;
104
111
  this._dom.el.style.width = `${this._cache.containerWidth}px`;
105
112
  this._dom.el.classList.remove('is-sticky-end');
113
+ document.body.dispatchEvent(this._eventEndChange);
114
+ if(this._callbackLeaveEnd) this._callbackLeaveEnd();
106
115
  }
107
116
  }
108
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",