@massimo-cassandro/minimo 0.14.3 → 0.15.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/massimo-cassandro/minimo#readme",
@@ -31,19 +31,20 @@ export function snackbar(message, options = {}){
31
31
  ...options
32
32
  };
33
33
 
34
- let _popover, _timeoutID;
34
+ let _popover, _timeoutID, _isRemoving = false;
35
35
 
36
36
  const removePopover = () => {
37
- if (_popover?.matches(':popover-open')) {
38
- if (_timeoutID) clearTimeout(_timeoutID);
37
+ if (_isRemoving || !_popover?.matches(':popover-open')) return;
38
+ _isRemoving = true; // evita sovrapposizioni nel caso in cui removePopover sia chiamato più volte durante l'animazione di chiusura
39
39
 
40
- _popover.classList.add(styles.isHiding);
40
+ if (_timeoutID) clearTimeout(_timeoutID);
41
41
 
42
- _popover.addEventListener('animationend', () => {
43
- _popover.hidePopover();
44
- _popover.remove();
45
- }, { once: true });
46
- }
42
+ _popover.classList.add(styles.isHiding);
43
+
44
+ _popover.addEventListener('animationend', () => {
45
+ _popover.hidePopover();
46
+ _popover.remove();
47
+ }, { once: true }); // `once` già evita duplicati sul listener, ma il flag protegge prima
47
48
  };
48
49
 
49
50
  _popover = domBuilder([
@@ -97,4 +98,8 @@ export function snackbar(message, options = {}){
97
98
  });
98
99
 
99
100
  }
101
+
102
+ return {
103
+ close: removePopover
104
+ };
100
105
  }