vgapp 0.5.9 → 0.6.1

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- # VEGAS-APP 0.5.6 - 0.5.9 (Август, 08, 2025)
1
+ # VEGAS-APP 0.5.6 - 0.6.1 (Август, 21, 2025)
2
2
  * Разделение JS и CSS
3
3
  * Исправлены ошибки в разных модулях
4
4
 
@@ -96,6 +96,47 @@ class BaseModule {
96
96
  new Animation(element, key, params);
97
97
  }
98
98
 
99
+ isMobileDevice() {
100
+ const userAgent = navigator.userAgent;
101
+ const isMobileUA = /Android|iPhone|iPad|iPod/i.test(userAgent);
102
+ const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 0;
103
+ const isSmallScreen = window.innerWidth < 768;
104
+ const isHighDPI = window.devicePixelRatio >= 2;
105
+
106
+ function detectIPadPro() {
107
+ const userAgent = navigator.userAgent;
108
+ const platform = navigator.platform;
109
+
110
+ const isIPad = /iPad/.test(userAgent) || (platform === 'MacIntel' && navigator.maxTouchPoints > 1);
111
+
112
+ if (!isIPad) return { isiPadPro: false };
113
+
114
+ const screenWidth = window.screen.width * window.devicePixelRatio;
115
+ const screenHeight = window.screen.height * window.devicePixelRatio;
116
+
117
+ const proResolutions = [
118
+ { width: 2048, height: 2732 }, // 12.9"
119
+ { width: 1668, height: 2388 }, // 11"
120
+ { width: 1668, height: 2224 } // 10.5"
121
+ ];
122
+
123
+ const isProResolution = proResolutions.some(res =>
124
+ (screenWidth === res.width && screenHeight === res.height) ||
125
+ (screenWidth === res.height && screenHeight === res.width)
126
+ );
127
+
128
+ return {
129
+ isiPadPro: isProResolution,
130
+ screenWidth: screenWidth,
131
+ screenHeight: screenHeight,
132
+ userAgent: userAgent,
133
+ platform: platform
134
+ };
135
+ }
136
+
137
+ return isMobileUA || (isTouchDevice && isSmallScreen && isHighDPI) || detectIPadPro().isiPadPro;
138
+ }
139
+
99
140
  static getInstance(element) {
100
141
  return Data.get(Selectors.find(element), this.NAME_KEY)
101
142
  }
@@ -35,7 +35,7 @@ class VGDropdown extends BaseModule {
35
35
  overflow: false,
36
36
  keyboard: false,
37
37
  placement: 'bottom',
38
- timeoutAnimation: 350,
38
+ timeoutAnimation: 10,
39
39
  hover: false,
40
40
  ajax: {
41
41
  route: '',
@@ -184,18 +184,11 @@ class VGDropdown extends BaseModule {
184
184
  const _this = this;
185
185
 
186
186
  if (!_this._isPlacement) {
187
- let placement = new Placement({
188
- element: this._parent,
189
- drop: this._drop
190
- })._getPlacement();
191
-
192
- if (placement.isFixed) {
193
- _this._drop.style.position = 'fixed';
194
- _this._drop.style.transform = 'translateY(-20%)'; // todo this is костыль поfixить
195
- }
187
+ const $placement = new Placement({
188
+ drop: _this._drop
189
+ })
196
190
 
197
- _this._drop.style.left = placement.left + 'px';
198
- _this._drop.style.top = placement.top + 'px';
191
+ $placement._setPlacement();
199
192
  }
200
193
 
201
194
  if (_this._params.offset) {
@@ -209,8 +202,9 @@ class VGDropdown extends BaseModule {
209
202
  static init(element, params = {}) {
210
203
  const instance = VGDropdown.getOrCreateInstance(element, params);
211
204
 
212
- if (instance._params.hover) {
205
+ if (instance._params.hover && !instance.isMobileDevice()) {
213
206
  let currentElem = null;
207
+
214
208
  EventHandler.on(instance._parent, EVENT_MOUSEOVER_DATA_API, function (event) {
215
209
  if (currentElem) return;
216
210
  VGDropdown.hideOpenToggles(event);
@@ -236,16 +230,16 @@ class VGDropdown extends BaseModule {
236
230
  currentElem = null;
237
231
  instance._completeHide({relatedTarget: instance._element});
238
232
  })
239
- } else {
240
- EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_DATA_TOGGLE, VGDropdown.keydownHandler);
241
- EventHandler.on(document, EVENT_KEYDOWN_DATA_API, '.' + TARGET_CONTAINER, VGDropdown.keydownHandler);
242
- EventHandler.on(document, EVENT_KEYUP_DATA_API, VGDropdown.clearDrops);
243
- EventHandler.on(document, EVENT_CLICK_DATA_API, VGDropdown.clearDrops);
244
- EventHandler.on(element, EVENT_CLICK_DATA_API, function (event) {
245
- event.preventDefault();
246
- instance.toggle();
247
- });
248
233
  }
234
+
235
+ EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_DATA_TOGGLE, VGDropdown.keydownHandler);
236
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, '.' + TARGET_CONTAINER, VGDropdown.keydownHandler);
237
+ EventHandler.on(document, EVENT_KEYUP_DATA_API, VGDropdown.clearDrops);
238
+ EventHandler.on(document, EVENT_CLICK_DATA_API, VGDropdown.clearDrops);
239
+ EventHandler.on(element, EVENT_CLICK_DATA_API, function (event) {
240
+ event.preventDefault();
241
+ instance.toggle();
242
+ });
249
243
  }
250
244
 
251
245
  static hideOpenToggles(event) {
@@ -17,11 +17,13 @@
17
17
 
18
18
  &-content {
19
19
  z-index: var(--vg-dropdown-z-index);
20
- position: absolute;
21
- opacity: 0;
22
20
  transform: translateY(20%);
23
21
  transition: var(--vg-dropdown-transition);
24
22
  min-width: var(--vg-dropdown-min-width);
23
+ position: absolute;
24
+ opacity: 0;
25
+ left: 0;
26
+ top: 100%;
25
27
 
26
28
  &:not(.show) {
27
29
  display: none;
@@ -35,6 +37,33 @@
35
37
  opacity: 1;
36
38
  transform: translateY(0);
37
39
  }
40
+
41
+ &.top {
42
+ bottom: 0;
43
+ }
44
+
45
+ &.bottom {
46
+ top: 0;
47
+ }
48
+
49
+ &.left {
50
+ left: 0;
51
+ }
52
+
53
+ &.right {
54
+ left: auto;
55
+ right: 0;
56
+ }
57
+
58
+ &.show {
59
+ &.top {
60
+ bottom: 100%;
61
+ }
62
+
63
+ &.bottom {
64
+ top: 100%;
65
+ }
66
+ }
38
67
  }
39
68
 
40
69
  &-container {