vgapp 1.0.7 → 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.
@@ -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 (this._params.collapse.open) {
322
- childList.classList.add("show");
323
- } else {
324
- childList.classList.remove("show");
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) {
@@ -281,6 +281,7 @@ class VGToast extends BaseModule {
281
281
  */
282
282
  hide() {
283
283
  if (isDisabled(this._element)) return;
284
+ this._clearTimeout();
284
285
 
285
286
  const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
286
287
  if (hideEvent.defaultPrevented) return;
@@ -289,14 +290,15 @@ class VGToast extends BaseModule {
289
290
 
290
291
  setTimeout(() => {
291
292
  this._element.classList.remove(CLASS_NAME_SHOW);
293
+ if (this._params.stack.enable) {
294
+ this._setPlacement();
295
+ }
292
296
 
293
297
  const completeCallback = () => {
294
- document.body.classList.remove(CLASS_NAME_OPEN);
295
- EventHandler.trigger(this._element, EVENT_KEY_HIDDEN);
296
-
297
- if (this._params.stack.enable) {
298
- this._setPlacement();
298
+ if (!Selectors.find('.vg-toast.show')) {
299
+ document.body.classList.remove(CLASS_NAME_OPEN);
299
300
  }
301
+ EventHandler.trigger(this._element, EVENT_KEY_HIDDEN);
300
302
 
301
303
  if (!this._params.static) {
302
304
  this.dispose();
@@ -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
 
@@ -389,15 +390,24 @@ class VGToast extends BaseModule {
389
390
  * @private
390
391
  */
391
392
  _setPlacement() {
392
- const elms = this._enableStack();
393
- const isCenter = this._params.placement.includes('center');
394
- const isLeft = this._params.placement.includes('left');
395
- const isRight = this._params.placement.includes('right');
393
+ const stackItems = this._enableStack();
396
394
  const isTop = this._params.placement.includes('top');
397
395
 
398
396
  const stackClass = isTop ? 'top' : 'bottom';
399
-
400
- elms.forEach(({ el, top }) => {
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 = '';
@@ -420,10 +430,12 @@ class VGToast extends BaseModule {
420
430
  }
421
431
 
422
432
  if (isTop) {
423
- style.top = top + 'px';
433
+ style.top = offset + 'px';
424
434
  } else {
425
- style.bottom = top + 'px';
435
+ style.bottom = offset + 'px';
426
436
  }
437
+
438
+ offset += el.offsetHeight;
427
439
  });
428
440
  }
429
441
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgapp",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "author": {
6
6
  "name": "Vegas Studio",