vgapp 1.0.8 → 1.0.9
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.
|
@@ -279,29 +279,29 @@ class VGToast extends BaseModule {
|
|
|
279
279
|
* Скрывает тост
|
|
280
280
|
* @returns {void}
|
|
281
281
|
*/
|
|
282
|
-
hide() {
|
|
283
|
-
if (isDisabled(this._element)) return;
|
|
284
|
-
this._clearTimeout();
|
|
285
|
-
|
|
286
|
-
const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
|
|
282
|
+
hide() {
|
|
283
|
+
if (isDisabled(this._element)) return;
|
|
284
|
+
this._clearTimeout();
|
|
285
|
+
|
|
286
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
|
|
287
287
|
if (hideEvent.defaultPrevented) return;
|
|
288
288
|
|
|
289
289
|
this._element.classList.remove(CLASS_NAME_SHOWN);
|
|
290
290
|
|
|
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.
|
|
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();
|
|
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.find('.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();
|
|
305
305
|
}
|
|
306
306
|
};
|
|
307
307
|
|
|
@@ -389,25 +389,25 @@ class VGToast extends BaseModule {
|
|
|
389
389
|
* Устанавливает позицию тостов с учётом стека
|
|
390
390
|
* @private
|
|
391
391
|
*/
|
|
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');
|
|
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');
|
|
411
411
|
const style = el.style;
|
|
412
412
|
style.left = '';
|
|
413
413
|
style.right = '';
|
|
@@ -429,15 +429,15 @@ class VGToast extends BaseModule {
|
|
|
429
429
|
style.translate = '-50% 0';
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
if (isTop) {
|
|
433
|
-
style.top = offset + 'px';
|
|
434
|
-
} else {
|
|
435
|
-
style.bottom = offset + 'px';
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
offset += el.offsetHeight;
|
|
439
|
-
});
|
|
440
|
-
}
|
|
432
|
+
if (isTop) {
|
|
433
|
+
style.top = offset + 'px';
|
|
434
|
+
} else {
|
|
435
|
+
style.bottom = offset + 'px';
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
offset += el.offsetHeight;
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
441
|
|
|
442
442
|
/**
|
|
443
443
|
* Очищает таймер
|
|
@@ -496,4 +496,4 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, functi
|
|
|
496
496
|
data.toggle(this);
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
-
export default VGToast;
|
|
499
|
+
export default VGToast;
|