vgapp 0.8.2 → 0.8.4
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.
|
@@ -137,6 +137,7 @@ class VGSidebar extends BaseModule {
|
|
|
137
137
|
toggle(relatedTarget) {
|
|
138
138
|
return this._isShown() ? this.hide() : this.show(relatedTarget);
|
|
139
139
|
}
|
|
140
|
+
_showPopstateHandler = null;
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
143
|
* Открывает сайдбар.
|
|
@@ -151,7 +152,6 @@ class VGSidebar extends BaseModule {
|
|
|
151
152
|
this._params = this._getParams(relatedTarget, this._params);
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
// Событие загрузки (может использоваться для AJAX)
|
|
155
155
|
this._route((status, data) => {
|
|
156
156
|
EventHandler.trigger(this._element, EVENT_KEYS.LOADED, { stats: status, data });
|
|
157
157
|
});
|
|
@@ -168,8 +168,14 @@ class VGSidebar extends BaseModule {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
if (this._params.hash) {
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
history.pushState(null, '', `#${this._element.id}`);
|
|
172
|
+
|
|
173
|
+
if (this._showPopstateHandler) {
|
|
174
|
+
EventHandler.off(window, EVENT_KEYS.POPSTATE_DATA_API, this._showPopstateHandler);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this._showPopstateHandler = () => this.hide();
|
|
178
|
+
EventHandler.on(window, EVENT_KEYS.POPSTATE_DATA_API, this._showPopstateHandler);
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
this._element.classList.add(CLASS_NAME_SHOW);
|
|
@@ -216,8 +222,17 @@ class VGSidebar extends BaseModule {
|
|
|
216
222
|
this._scrollBar.reset();
|
|
217
223
|
}
|
|
218
224
|
|
|
219
|
-
if (this._params.hash) {
|
|
220
|
-
history.replaceState(
|
|
225
|
+
if (this._params.hash && window.location.hash === `#${this._element.id}`) {
|
|
226
|
+
history.replaceState(
|
|
227
|
+
'',
|
|
228
|
+
document.title,
|
|
229
|
+
window.location.pathname + window.location.search
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this._showPopstateHandler) {
|
|
234
|
+
EventHandler.off(window, EVENT_KEYS.POPSTATE_DATA_API, this._showPopstateHandler);
|
|
235
|
+
this._showPopstateHandler = null;
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
EventHandler.trigger(this._element, EVENT_KEYS.HIDDEN);
|
|
@@ -235,7 +250,9 @@ class VGSidebar extends BaseModule {
|
|
|
235
250
|
dispose() {
|
|
236
251
|
super.dispose();
|
|
237
252
|
EventHandler.off(this._element, EVENT_KEYS.HIDE);
|
|
238
|
-
|
|
253
|
+
if (this._showPopstateHandler) {
|
|
254
|
+
EventHandler.off(window, EVENT_KEYS.POPSTATE_DATA_API, this._showPopstateHandler);
|
|
255
|
+
}
|
|
239
256
|
this._scrollBar.reset();
|
|
240
257
|
}
|
|
241
258
|
|
|
@@ -326,7 +343,10 @@ EventHandler.on(document, EVENT_KEYS.DOM_LOADED_DATA_API, function () {
|
|
|
326
343
|
const target = Selectors.find(`#${hash}`);
|
|
327
344
|
if (target && target.classList.contains('vg-sidebar') && !isDisabled(target)) {
|
|
328
345
|
const instance = VGSidebar.getOrCreateInstance(target);
|
|
329
|
-
|
|
346
|
+
|
|
347
|
+
if (instance._params.hash) {
|
|
348
|
+
instance.toggle();
|
|
349
|
+
}
|
|
330
350
|
}
|
|
331
351
|
});
|
|
332
352
|
|
|
@@ -13,7 +13,10 @@ const EVENT_MOUSEDOWN = `mousedown.vg.${NAME}`;
|
|
|
13
13
|
const backdropDelay = 150; // Уменьшено для более плавного UX
|
|
14
14
|
|
|
15
15
|
class Backdrop {
|
|
16
|
-
static _rootEl
|
|
16
|
+
static get _rootEl() {
|
|
17
|
+
return document.body;
|
|
18
|
+
}
|
|
19
|
+
|
|
17
20
|
static _scrollbar = new ScrollBarHelper();
|
|
18
21
|
static _backdrop = null;
|
|
19
22
|
|