@profitlich/template-toolkit 5.2.0 → 5.2.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.
|
@@ -25,6 +25,7 @@ export class MenuToggle {
|
|
|
25
25
|
#deferPositionFixed;
|
|
26
26
|
#lockScroll;
|
|
27
27
|
#fixElement;
|
|
28
|
+
#fixElementIsBody;
|
|
28
29
|
#y;
|
|
29
30
|
#bodyClickHandler;
|
|
30
31
|
#resizeHandler;
|
|
@@ -54,6 +55,7 @@ export class MenuToggle {
|
|
|
54
55
|
this.#deferPositionFixed = deferPositionFixed;
|
|
55
56
|
this.#lockScroll = lockScroll;
|
|
56
57
|
this.#fixElement = fixElementSelector ? document.querySelector(fixElementSelector) : document.body;
|
|
58
|
+
this.#fixElementIsBody = this.#fixElement === document.body;
|
|
57
59
|
this.#scrollbarWidth = 0;
|
|
58
60
|
this.isActive = false;
|
|
59
61
|
this.#y = 0;
|
|
@@ -108,7 +110,9 @@ export class MenuToggle {
|
|
|
108
110
|
this.#shiftElement.style.marginRight = '';
|
|
109
111
|
this.#shiftElement.style.width = '';
|
|
110
112
|
}
|
|
111
|
-
this.#
|
|
113
|
+
if (this.#fixElementIsBody) {
|
|
114
|
+
this.#fixElement.style.paddingRight = '';
|
|
115
|
+
}
|
|
112
116
|
this.#fixElement.style.top = '';
|
|
113
117
|
window.scrollTo(0, this.#y);
|
|
114
118
|
}
|
|
@@ -121,15 +125,11 @@ export class MenuToggle {
|
|
|
121
125
|
window.addEventListener('resize', this.#resizeHandler);
|
|
122
126
|
this.#setBodyAttribute('data-menu-moving', 'true');
|
|
123
127
|
if (!this.#deferPositionFixed) {
|
|
124
|
-
this.#
|
|
128
|
+
this.#applyFix();
|
|
125
129
|
}
|
|
126
130
|
setTimeout(() => {
|
|
127
|
-
this.#scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
128
|
-
this.#y = window.scrollY;
|
|
129
|
-
this.#fixElement.style.paddingRight = `${this.#scrollbarWidth}px`;
|
|
130
|
-
this.#fixElement.style.top = `-${this.#y}px`;
|
|
131
131
|
if (this.#deferPositionFixed) {
|
|
132
|
-
this.#
|
|
132
|
+
this.#applyFix();
|
|
133
133
|
}
|
|
134
134
|
if (this.#shiftElement) {
|
|
135
135
|
const marginOriginal = parseFloat(window.getComputedStyle(this.#menuButton).marginRight);
|
|
@@ -147,6 +147,18 @@ export class MenuToggle {
|
|
|
147
147
|
document.dispatchEvent(event);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
// Scrollbar-Ausgleich nur nötig, wenn der Body fixiert wird –
|
|
151
|
+
// bei anderem #fixElement bleibt die Seiten-Scrollbar bestehen.
|
|
152
|
+
#applyFix() {
|
|
153
|
+
this.#scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
154
|
+
this.#y = window.scrollY;
|
|
155
|
+
if (this.#fixElementIsBody) {
|
|
156
|
+
this.#fixElement.style.paddingRight = `${this.#scrollbarWidth}px`;
|
|
157
|
+
}
|
|
158
|
+
this.#fixElement.style.top = `-${this.#y}px`;
|
|
159
|
+
this.#fixElement.setAttribute('data-menu-fixed', 'true');
|
|
160
|
+
}
|
|
161
|
+
|
|
150
162
|
#adjustShiftElementWidth() {
|
|
151
163
|
const contentWidth = document.documentElement.clientWidth;
|
|
152
164
|
this.#shiftElement.style.width = `${contentWidth - this.#scrollbarWidth}px`;
|
package/package.json
CHANGED