@madj2k/fe-frontend-kit 2.0.36 → 2.0.37
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/menus/flyout-menu/flyout-menu-2.0.js +60 -15
- package/package.json +1 -1
- package/readme.md +83 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @author Steffen Kroggel <developer@steffenkroggel.de>
|
|
9
9
|
* @copyright 2025 Steffen Kroggel
|
|
10
|
-
* @version 2.0.
|
|
10
|
+
* @version 2.0.2
|
|
11
11
|
* @license GNU General Public License v3.0
|
|
12
12
|
* @see https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
13
13
|
*
|
|
@@ -51,9 +51,13 @@ class Madj2kFlyoutMenu {
|
|
|
51
51
|
menuInnerClass: "js-flyout-inner",
|
|
52
52
|
heightCalculationClass: 'calculate',
|
|
53
53
|
heightMode: 'full',
|
|
54
|
+
eventMode: 'click',
|
|
55
|
+
eventModeOpen: '',
|
|
56
|
+
eventModeClose: '',
|
|
54
57
|
paddingBehavior: 0,
|
|
55
58
|
paddingViewPortMinWidth: 0,
|
|
56
|
-
animationDuration: 500
|
|
59
|
+
animationDuration: 500,
|
|
60
|
+
scrollHelper: true,
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
this.settings = Object.assign({}, defaults, options);
|
|
@@ -116,11 +120,26 @@ class Madj2kFlyoutMenu {
|
|
|
116
120
|
*/
|
|
117
121
|
bindEvents() {
|
|
118
122
|
if (this.settings.$closeBtn) {
|
|
119
|
-
|
|
123
|
+
|
|
124
|
+
if (this.settings.eventModeClose) {
|
|
125
|
+
this.settings.$closeBtn.addEventListener(this.settings.eventModeClose, e => this.closeEvent(e));
|
|
126
|
+
} else {
|
|
127
|
+
this.settings.$closeBtn.addEventListener(this.settings.eventMode, e => this.closeEvent(e));
|
|
128
|
+
}
|
|
120
129
|
this.settings.$closeBtn.addEventListener('keydown', e => this.keyboardEvent(e));
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
this
|
|
132
|
+
if (this.settings.eventModeOpen || this.settings.eventModeClose) {
|
|
133
|
+
if (this.settings.eventModeOpen) {
|
|
134
|
+
this.$element.addEventListener(this.settings.eventModeOpen, e => this.openEvent(e));
|
|
135
|
+
}
|
|
136
|
+
if (this.settings.eventModeClose) {
|
|
137
|
+
this.$element.addEventListener(this.settings.eventModeClose, e => this.closeEvent(e));
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
this.$element.addEventListener(this.settings.eventMode, e => this.toggleEvent(e));
|
|
141
|
+
}
|
|
142
|
+
|
|
124
143
|
this.$element.addEventListener('keydown', e => this.keyboardEvent(e));
|
|
125
144
|
|
|
126
145
|
this.settings.$menu.querySelectorAll('a,button,input,textarea,select')
|
|
@@ -158,11 +177,24 @@ class Madj2kFlyoutMenu {
|
|
|
158
177
|
*/
|
|
159
178
|
destroyEvents() {
|
|
160
179
|
if (this.settings.$closeBtn) {
|
|
161
|
-
this.settings
|
|
180
|
+
if (this.settings.eventModeClose) {
|
|
181
|
+
this.settings.$closeBtn.removeEventListener(this.settings.eventModeClose, e => this.closeEvent(e));
|
|
182
|
+
} else {
|
|
183
|
+
this.settings.$closeBtn.removeEventListener(this.settings.eventMode, e => this.closeEvent(e));
|
|
184
|
+
}
|
|
162
185
|
this.settings.$closeBtn.removeEventListener('keydown', e => this.keyboardEvent(e));
|
|
163
186
|
}
|
|
164
187
|
|
|
165
|
-
this
|
|
188
|
+
if (this.settings.eventModeOpen || this.settings.eventModeClose) {
|
|
189
|
+
if (this.settings.eventModeOpen) {
|
|
190
|
+
this.$element.removeEventListener(this.settings.eventModeOpen, e => this.openEvent(e));
|
|
191
|
+
}
|
|
192
|
+
if (this.settings.eventModeClose) {
|
|
193
|
+
this.$element.removeEventListener(this.settings.eventModeClose, e => this.closeEvent(e));
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
this.$element.removeEventListener(this.settings.eventMode, e => this.toggleEvent(e));
|
|
197
|
+
}
|
|
166
198
|
this.$element.removeEventListener('keydown', e => this.keyboardEvent(e));
|
|
167
199
|
|
|
168
200
|
this.settings.$menu.querySelectorAll('a,button,input,textarea,select')
|
|
@@ -227,6 +259,16 @@ class Madj2kFlyoutMenu {
|
|
|
227
259
|
}
|
|
228
260
|
|
|
229
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Handles close event
|
|
264
|
+
* @param {Event} e - The close event
|
|
265
|
+
*/
|
|
266
|
+
openEvent(e) {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
this.open();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
230
272
|
/**
|
|
231
273
|
* Opens the flyout menu
|
|
232
274
|
*/
|
|
@@ -408,15 +450,19 @@ class Madj2kFlyoutMenu {
|
|
|
408
450
|
* Initializes the no-scroll helper elements
|
|
409
451
|
*/
|
|
410
452
|
initNoScrollHelper() {
|
|
411
|
-
const body = document.body;
|
|
412
|
-
let helper = body.querySelector('.no-scroll-helper');
|
|
413
|
-
const content = document.querySelector(`.${this.settings.contentSectionClass}`);
|
|
414
453
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
454
|
+
// heightMode "full" with deprecated fullHeight-setting as fallback
|
|
455
|
+
if (this.settings.scrollHelper) {
|
|
456
|
+
const body = document.body;
|
|
457
|
+
let helper = body.querySelector('.no-scroll-helper');
|
|
458
|
+
const content = document.querySelector(`.${this.settings.contentSectionClass}`);
|
|
459
|
+
|
|
460
|
+
if (!helper) {
|
|
461
|
+
if (content) {
|
|
462
|
+
content.innerHTML = `<div class="no-scroll-helper"><div class="no-scroll-helper-inner">${content.innerHTML}</div></div>`;
|
|
463
|
+
} else {
|
|
464
|
+
body.innerHTML = `<div class="no-scroll-helper"><div class="no-scroll-helper-inner">${body.innerHTML}</div></div>`;
|
|
465
|
+
}
|
|
420
466
|
}
|
|
421
467
|
}
|
|
422
468
|
}
|
|
@@ -451,7 +497,6 @@ class Madj2kFlyoutMenu {
|
|
|
451
497
|
body.classList.remove(this.settings.openStatusBodyClassOverflow);
|
|
452
498
|
window.scrollTo({top: scrollTop, behavior: 'instant'});
|
|
453
499
|
}
|
|
454
|
-
|
|
455
500
|
}
|
|
456
501
|
}
|
|
457
502
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -79,7 +79,7 @@ CSS:
|
|
|
79
79
|
</nav>
|
|
80
80
|
</div>
|
|
81
81
|
```
|
|
82
|
-
IMPORTANT: If the siteheader is positioned with ```position:fixed
|
|
82
|
+
IMPORTANT: If the siteheader is positioned with ```position:fixed``` and you are using full-height-mode (which is the default) you have to switch that to ```position:absolute``` when the menu is opened.
|
|
83
83
|
Otherwise in the opened menu the scrolling won't work.
|
|
84
84
|
```
|
|
85
85
|
.flyout-open {
|
|
@@ -88,6 +88,58 @@ Otherwise in the opened menu the scrolling won't work.
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Options Reference
|
|
94
|
+
|
|
95
|
+
### State & Animation Classes
|
|
96
|
+
|
|
97
|
+
| Option | Type | Default | Description |
|
|
98
|
+
|--------|------|---------|-------------|
|
|
99
|
+
| openStatusClass | string | 'open' | Applied to trigger and menu when open. |
|
|
100
|
+
| animationOpenStatusClass | string | 'opening' | Applied during opening animation. |
|
|
101
|
+
| animationCloseStatusClass | string | 'closing' | Applied during closing animation. |
|
|
102
|
+
| animationBodyClassPrefix | string | 'flyout' | Prefix for body animation classes like `flyout-opening`. |
|
|
103
|
+
| openStatusBodyClass | string | 'flyout-open' | Applied to `body` when the flyout is open. |
|
|
104
|
+
| openStatusBodyClassOverflow | string | 'flyout-open-overflow' | Applied when page height exceeds viewport (used in scroll-locking). |
|
|
105
|
+
|
|
106
|
+
### CSS Class Selectors
|
|
107
|
+
|
|
108
|
+
| Option | Type | Default | Description |
|
|
109
|
+
|--------|------|---------|-------------|
|
|
110
|
+
| contentSectionClass | string | 'js-main-content' | Content wrapper used when creating no-scroll helper. |
|
|
111
|
+
| menuClass | string | 'js-flyout' | Menu root element class. |
|
|
112
|
+
| menuToggleClass | string | 'js-flyout-toggle' | Class for toggle buttons. |
|
|
113
|
+
| menuCloseClass | string | 'js-flyout-close' | Class for close buttons inside the flyout. |
|
|
114
|
+
| menuContainerClass | string | 'js-flyout-container' | Container used for slide animations (`top` transition). |
|
|
115
|
+
| menuInnerClass | string | 'js-flyout-inner' | Inner content wrapper. Observed via ResizeObserver. |
|
|
116
|
+
| heightCalculationClass | string | 'calculate' | Temporary class used during height determination. |
|
|
117
|
+
|
|
118
|
+
### Height & Size Behavior
|
|
119
|
+
|
|
120
|
+
| Option | Type | Default | Description |
|
|
121
|
+
|--------|------|---------|-------------|
|
|
122
|
+
| heightMode | 'full' \| 'maxContent' | 'full' | Determines height behavior of the flyout. |
|
|
123
|
+
| animationDuration | number | 500 | Animation duration in milliseconds. |
|
|
124
|
+
|
|
125
|
+
### Padding & Layout Behavior
|
|
126
|
+
|
|
127
|
+
| Option | Type | Default | Description |
|
|
128
|
+
|--------|------|---------|-------------|
|
|
129
|
+
| paddingBehavior | number | 0 | Controls dynamic horizontal padding. |
|
|
130
|
+
| paddingViewPortMinWidth | number | 0 | Minimum viewport width required before padding applies. |
|
|
131
|
+
| scrollHelper | boolean | true | Creates additional wrapper structure to enable scroll-locking. |
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### Event Handling
|
|
135
|
+
|
|
136
|
+
| Option | Type | Default | Description |
|
|
137
|
+
|--------|------|-------------|
|
|
138
|
+
| `eventMode` | `string` | `'click'` | Default event used for toggling the menu. Replaced if `eventModeOpen` or `eventModeClose` are set. |
|
|
139
|
+
| `eventModeOpen` | `string` | `''` | Defines a custom event for opening the menu. |
|
|
140
|
+
| `eventModeClose` | `string` | `''` | Defines a custom event for closing the menu. |
|
|
141
|
+
|
|
142
|
+
|
|
91
143
|
## Special: blur/gray effect for background
|
|
92
144
|
* In order to achieve a blur/gray-effect for the background we add the following DIV to the main-content section:
|
|
93
145
|
```
|
|
@@ -199,6 +251,36 @@ CSS:
|
|
|
199
251
|
```
|
|
200
252
|
|
|
201
253
|
|
|
254
|
+
## Options Reference
|
|
255
|
+
|
|
256
|
+
### State & Structural Classes
|
|
257
|
+
|
|
258
|
+
| Option | Type | Default | Description |
|
|
259
|
+
|--------|------|---------|-------------|
|
|
260
|
+
| **openStatusClass** | `string` | `'open'` | Applied to menu, wrapper, and toggle when the pulldown is open. |
|
|
261
|
+
| **menuClass** | `string` | `'js-pulldown'` | Root class of the pulldown menu. Must match your HTML structure. |
|
|
262
|
+
| **menuToggleClass** | `string` | `'js-pulldown-toggle'` | Toggle buttons that control pulldown menus and also close others. |
|
|
263
|
+
| **menuWrapClass** | `string` | `'js-pulldown-wrap'` | Optional wrapper container that receives open/closed states. |
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
### Animation & Timing
|
|
267
|
+
|
|
268
|
+
| Option | Type | Default | Description |
|
|
269
|
+
|--------|------|---------|-------------|
|
|
270
|
+
| **animationDuration** | `number` | `500` | Reserved for future open/close animation timing. Currently no CSS transition is applied by JavaScript. |
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
### Internal Element References
|
|
274
|
+
|
|
275
|
+
These are automatically detected:
|
|
276
|
+
|
|
277
|
+
| Property | Description |
|
|
278
|
+
|----------|-------------|
|
|
279
|
+
| **menu** | The menu element referenced via `aria-controls`. |
|
|
280
|
+
| **menuWrap** | Closest parent using `menuWrapClass`. |
|
|
281
|
+
| **toggleElement** | The trigger element passed to the constructor. |
|
|
282
|
+
|
|
283
|
+
|
|
202
284
|
# JS: Banner
|
|
203
285
|
A lightweight class to show a full-page overlay (banner, popup, hint or cookie layer),
|
|
204
286
|
with opening and closing animation and optional cookie persistence.
|