vgapp 1.0.7 → 1.0.8
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.
|
@@ -101,8 +101,6 @@ class VGNestable extends BaseModule {
|
|
|
101
101
|
this._isDragging = false;
|
|
102
102
|
this._startSnapshot = "";
|
|
103
103
|
this._sourceInstance = this;
|
|
104
|
-
this._sourceRoot = null;
|
|
105
|
-
this._currentTargetInstance = this;
|
|
106
104
|
this._lastDropInstance = this;
|
|
107
105
|
this._activeDropList = null;
|
|
108
106
|
|
|
@@ -317,11 +315,14 @@ class VGNestable extends BaseModule {
|
|
|
317
315
|
childList.id = `vg-nestable-collapse-${Math.random().toString(36).slice(2, 10)}`;
|
|
318
316
|
}
|
|
319
317
|
|
|
318
|
+
const hasCollapseClass = childList.classList.contains("vg-collapse");
|
|
320
319
|
childList.classList.add("vg-collapse");
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
320
|
+
if (!hasCollapseClass) {
|
|
321
|
+
if (this._params.collapse.open) {
|
|
322
|
+
childList.classList.add("show");
|
|
323
|
+
} else {
|
|
324
|
+
childList.classList.remove("show");
|
|
325
|
+
}
|
|
325
326
|
}
|
|
326
327
|
|
|
327
328
|
if (!toggle) {
|
|
@@ -279,27 +279,29 @@ class VGToast extends BaseModule {
|
|
|
279
279
|
* Скрывает тост
|
|
280
280
|
* @returns {void}
|
|
281
281
|
*/
|
|
282
|
-
hide() {
|
|
283
|
-
if (isDisabled(this._element)) return;
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
hide() {
|
|
283
|
+
if (isDisabled(this._element)) return;
|
|
284
|
+
this._clearTimeout();
|
|
285
|
+
|
|
286
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
|
|
286
287
|
if (hideEvent.defaultPrevented) return;
|
|
287
288
|
|
|
288
289
|
this._element.classList.remove(CLASS_NAME_SHOWN);
|
|
289
290
|
|
|
290
|
-
setTimeout(() => {
|
|
291
|
-
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
291
|
+
setTimeout(() => {
|
|
292
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
293
|
+
if (this._params.stack.enable) {
|
|
294
|
+
this._setPlacement();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const completeCallback = () => {
|
|
298
|
+
if (!Selectors.findOne('.vg-toast.show')) {
|
|
299
|
+
document.body.classList.remove(CLASS_NAME_OPEN);
|
|
300
|
+
}
|
|
301
|
+
EventHandler.trigger(this._element, EVENT_KEY_HIDDEN);
|
|
302
|
+
|
|
303
|
+
if (!this._params.static) {
|
|
304
|
+
this.dispose();
|
|
303
305
|
}
|
|
304
306
|
};
|
|
305
307
|
|
|
@@ -346,7 +348,6 @@ class VGToast extends BaseModule {
|
|
|
346
348
|
*/
|
|
347
349
|
_enableStack() {
|
|
348
350
|
const placement = this._params.placement;
|
|
349
|
-
const isVerticalCenter = placement.includes('center');
|
|
350
351
|
const isTop = placement.includes('top');
|
|
351
352
|
const isBottom = !isTop; // по умолчанию снизу
|
|
352
353
|
|
|
@@ -388,16 +389,25 @@ class VGToast extends BaseModule {
|
|
|
388
389
|
* Устанавливает позицию тостов с учётом стека
|
|
389
390
|
* @private
|
|
390
391
|
*/
|
|
391
|
-
_setPlacement() {
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
392
|
+
_setPlacement() {
|
|
393
|
+
const stackItems = this._enableStack();
|
|
394
|
+
const isTop = this._params.placement.includes('top');
|
|
395
|
+
|
|
396
|
+
const stackClass = isTop ? 'top' : 'bottom';
|
|
397
|
+
const visibleStack = Selectors.findAll(`.vg-toast.show.${stackClass}`)
|
|
398
|
+
.filter(el => {
|
|
399
|
+
const instance = VGToast.getInstance(el);
|
|
400
|
+
return instance?._params.stack.enable;
|
|
401
|
+
});
|
|
402
|
+
const elms = visibleStack.length ? visibleStack : stackItems.map(item => item.el);
|
|
403
|
+
let offset = 0;
|
|
404
|
+
|
|
405
|
+
elms.forEach((el) => {
|
|
406
|
+
const instance = VGToast.getInstance(el);
|
|
407
|
+
const placement = instance?._params.placement || this._params.placement;
|
|
408
|
+
const isCenter = placement.includes('center');
|
|
409
|
+
const isLeft = placement.includes('left');
|
|
410
|
+
const isRight = placement.includes('right');
|
|
401
411
|
const style = el.style;
|
|
402
412
|
style.left = '';
|
|
403
413
|
style.right = '';
|
|
@@ -419,13 +429,15 @@ class VGToast extends BaseModule {
|
|
|
419
429
|
style.translate = '-50% 0';
|
|
420
430
|
}
|
|
421
431
|
|
|
422
|
-
if (isTop) {
|
|
423
|
-
style.top =
|
|
424
|
-
} else {
|
|
425
|
-
style.bottom =
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
432
|
+
if (isTop) {
|
|
433
|
+
style.top = offset + 'px';
|
|
434
|
+
} else {
|
|
435
|
+
style.bottom = offset + 'px';
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
offset += el.offsetHeight;
|
|
439
|
+
});
|
|
440
|
+
}
|
|
429
441
|
|
|
430
442
|
/**
|
|
431
443
|
* Очищает таймер
|
|
@@ -484,4 +496,4 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, functi
|
|
|
484
496
|
data.toggle(this);
|
|
485
497
|
});
|
|
486
498
|
|
|
487
|
-
export default VGToast;
|
|
499
|
+
export default VGToast;
|