vgapp 0.8.5 → 0.8.7
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 +5 -0
- package/app/modules/base-module.js +0 -41
- package/app/modules/vgdropdown/js/vgdropdown.js +2 -2
- package/app/modules/vgfiles/js/vgfiles.js +2 -5
- package/app/modules/vgnav/js/vgnav.js +11 -3
- package/app/utils/js/components/backdrop.js +19 -1
- package/app/utils/js/components/scrollbar.js +12 -12
- package/app/utils/js/functions.js +42 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -154,47 +154,6 @@ class BaseModule {
|
|
|
154
154
|
new Animation(element, key, params);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
isMobileDevice() {
|
|
158
|
-
const userAgent = navigator.userAgent;
|
|
159
|
-
const isMobileUA = /Android|iPhone|iPad|iPod/i.test(userAgent);
|
|
160
|
-
const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
161
|
-
const isSmallScreen = window.innerWidth < 768;
|
|
162
|
-
const isHighDPI = window.devicePixelRatio >= 2;
|
|
163
|
-
|
|
164
|
-
function detectIPadPro() {
|
|
165
|
-
const userAgent = navigator.userAgent;
|
|
166
|
-
const platform = navigator.platform;
|
|
167
|
-
|
|
168
|
-
const isIPad = /iPad/.test(userAgent) || (platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
|
169
|
-
|
|
170
|
-
if (!isIPad) return { isiPadPro: false };
|
|
171
|
-
|
|
172
|
-
const screenWidth = window.screen.width * window.devicePixelRatio;
|
|
173
|
-
const screenHeight = window.screen.height * window.devicePixelRatio;
|
|
174
|
-
|
|
175
|
-
const proResolutions = [
|
|
176
|
-
{ width: 2048, height: 2732 }, // 12.9"
|
|
177
|
-
{ width: 1668, height: 2388 }, // 11"
|
|
178
|
-
{ width: 1668, height: 2224 } // 10.5"
|
|
179
|
-
];
|
|
180
|
-
|
|
181
|
-
const isProResolution = proResolutions.some(res =>
|
|
182
|
-
(screenWidth === res.width && screenHeight === res.height) ||
|
|
183
|
-
(screenWidth === res.height && screenHeight === res.width)
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
isiPadPro: isProResolution,
|
|
188
|
-
screenWidth: screenWidth,
|
|
189
|
-
screenHeight: screenHeight,
|
|
190
|
-
userAgent: userAgent,
|
|
191
|
-
platform: platform
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return isMobileUA || (isTouchDevice && isSmallScreen && isHighDPI) || detectIPadPro().isiPadPro;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
157
|
static getInstance(element) {
|
|
199
158
|
return Data.get(Selectors.find(element), this.NAME_KEY)
|
|
200
159
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseModule from "../../base-module";
|
|
2
2
|
import EventHandler from "../../../utils/js/dom/event";
|
|
3
3
|
import Selectors from "../../../utils/js/dom/selectors";
|
|
4
|
-
import {isDisabled, mergeDeepObject, noop} from "../../../utils/js/functions";
|
|
4
|
+
import {isDisabled, isMobileDevice, mergeDeepObject, noop} from "../../../utils/js/functions";
|
|
5
5
|
import Placement from "../../../utils/js/components/placement";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -299,7 +299,7 @@ class VGDropdown extends BaseModule {
|
|
|
299
299
|
static init(element, params = {}) {
|
|
300
300
|
const instance = VGDropdown.getOrCreateInstance(element, params);
|
|
301
301
|
|
|
302
|
-
if (instance._params.hover && !
|
|
302
|
+
if (instance._params.hover && !isMobileDevice()) {
|
|
303
303
|
let currentElem = null;
|
|
304
304
|
|
|
305
305
|
EventHandler.on(instance._parent, EVENT_MOUSEOVER_DATA_API, (event) => {
|
|
@@ -10,6 +10,7 @@ import {lang_buttons, lang_messages} from "../../../utils/js/components/lang";
|
|
|
10
10
|
import VGAlert from "../../vgalert";
|
|
11
11
|
import VGToast from "../../vgtoast";
|
|
12
12
|
import VGFilesTemplateRender from "./render";
|
|
13
|
+
import VGFilesSortable from "./sortable";
|
|
13
14
|
|
|
14
15
|
const NAME = 'files';
|
|
15
16
|
const NAME_KEY = 'vg.files';
|
|
@@ -168,11 +169,7 @@ class VGFiles extends VGFilesBase {
|
|
|
168
169
|
|
|
169
170
|
// Если нужно — запустить sortable
|
|
170
171
|
if (this._params.sortable?.enabled && this._params.sortable.route && !this._sortable) {
|
|
171
|
-
|
|
172
|
-
this._sortable = new module.default(this, this._params.sortable);
|
|
173
|
-
}).catch(err => {
|
|
174
|
-
console.error('Ошибка загрузки VGFilesSortable:', err);
|
|
175
|
-
});
|
|
172
|
+
this._sortable = new VGFilesSortable(this, this._params.sortable)
|
|
176
173
|
}
|
|
177
174
|
|
|
178
175
|
// Триггерим изменение
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import BaseModule from "../../base-module";
|
|
2
2
|
import Selectors from "../../../utils/js/dom/selectors";
|
|
3
3
|
import {getSVG} from "../../module-fn";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
execute,
|
|
6
|
+
isDisabled,
|
|
7
|
+
isMobileDevice,
|
|
8
|
+
isVisible,
|
|
9
|
+
mergeDeepObject,
|
|
10
|
+
noop,
|
|
11
|
+
normalizeData
|
|
12
|
+
} from "../../../utils/js/functions";
|
|
5
13
|
import EventHandler from "../../../utils/js/dom/event";
|
|
6
14
|
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
7
15
|
import Placement from "../../../utils/js/components/placement";
|
|
@@ -332,7 +340,7 @@ class VGNav extends BaseModule {
|
|
|
332
340
|
|
|
333
341
|
let drops = Selectors.findAll('.dropdown', instance.navigation);
|
|
334
342
|
|
|
335
|
-
if (instance._params.hover && !
|
|
343
|
+
if (instance._params.hover && !isMobileDevice()) {
|
|
336
344
|
[...drops].forEach(function (el) {
|
|
337
345
|
let currentElem = null;
|
|
338
346
|
|
|
@@ -431,7 +439,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
|
|
|
431
439
|
execute(instance._params.callbacks.afterClick, [instance, event, this]);
|
|
432
440
|
}
|
|
433
441
|
|
|
434
|
-
if (instance._params.hover && !
|
|
442
|
+
if (instance._params.hover && !isMobileDevice()) return;
|
|
435
443
|
|
|
436
444
|
event.preventDefault();
|
|
437
445
|
|
|
@@ -10,7 +10,7 @@ const CLASS_NAME_FADE = 'fade';
|
|
|
10
10
|
const CLASS_NAME_SHOW = 'show';
|
|
11
11
|
const EVENT_MOUSEDOWN = `mousedown.vg.${NAME}`;
|
|
12
12
|
|
|
13
|
-
const backdropDelay = 150;
|
|
13
|
+
const backdropDelay = 150;
|
|
14
14
|
|
|
15
15
|
class Backdrop {
|
|
16
16
|
static get _rootEl() {
|
|
@@ -25,7 +25,20 @@ class Backdrop {
|
|
|
25
25
|
* @param {Function} callback - вызывается после отображения
|
|
26
26
|
*/
|
|
27
27
|
static show(callback) {
|
|
28
|
+
// Проверяем, существует ли бэкдроп в DOM, даже если _backdrop === null
|
|
28
29
|
if (!this._backdrop) {
|
|
30
|
+
this._backdrop = this._rootEl.querySelector(`.${CLASS_NAME}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Если найден в DOM — используем его
|
|
34
|
+
if (this._backdrop) {
|
|
35
|
+
// Убеждаемся, что классы корректны
|
|
36
|
+
Classes.add(this._backdrop, CLASS_NAME_SHOW);
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
Classes.add(this._backdrop, CLASS_NAME_FADE);
|
|
39
|
+
}, backdropDelay);
|
|
40
|
+
} else {
|
|
41
|
+
// Создаём новый, если не найден
|
|
29
42
|
this._append();
|
|
30
43
|
}
|
|
31
44
|
|
|
@@ -37,6 +50,11 @@ class Backdrop {
|
|
|
37
50
|
* @param {Function} callback - вызывается после скрытия
|
|
38
51
|
*/
|
|
39
52
|
static hide(callback) {
|
|
53
|
+
if (!this._backdrop) {
|
|
54
|
+
// На всякий случай проверим, есть ли элемент в DOM
|
|
55
|
+
this._backdrop = this._rootEl.querySelector(`.${CLASS_NAME}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
40
58
|
if (!this._backdrop) return;
|
|
41
59
|
|
|
42
60
|
this._destroy().then(execute.bind(null, callback));
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { Manipulator } from "../dom/manipulator";
|
|
12
12
|
import Selectors from "../dom/selectors";
|
|
13
|
-
import {
|
|
13
|
+
import {isElement, isMobileDevice} from "../functions";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Константы
|
|
@@ -50,14 +50,16 @@ class ScrollBarHelper {
|
|
|
50
50
|
* Скрывает скроллбар и корректирует макет
|
|
51
51
|
*/
|
|
52
52
|
hide() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
if (this.isOverflowing && !isMobileDevice()) {
|
|
54
|
+
const width = this.getWidth();
|
|
55
|
+
this._disableOverflow();
|
|
56
|
+
|
|
57
|
+
this._setStyle(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, width, (value) => value + width);
|
|
58
|
+
this._setStyle(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, width, (value) => value - width);
|
|
59
|
+
this._setStyle(this._element, PROPERTY_PADDING, width, (value) => value + width);
|
|
60
|
+
} else if (isMobileDevice()) {
|
|
61
|
+
this._disableOverflow();
|
|
62
|
+
}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|
|
@@ -70,8 +72,6 @@ class ScrollBarHelper {
|
|
|
70
72
|
this._resetStyle(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
// === Приватные методы ===
|
|
74
|
-
|
|
75
75
|
/**
|
|
76
76
|
* Блокирует overflow у body
|
|
77
77
|
* @private
|
|
@@ -142,7 +142,7 @@ class ScrollBarHelper {
|
|
|
142
142
|
// Важно: сохраняем даже пустую строку (если inline-стиля не было)
|
|
143
143
|
// чтобы reset() мог корректно восстановить "как было".
|
|
144
144
|
if (value !== null) {
|
|
145
|
-
Manipulator.set(element, property, value);
|
|
145
|
+
//Manipulator.set(element, property, value);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -309,6 +309,47 @@ const getDeepestLastChild = (el) => {
|
|
|
309
309
|
*/
|
|
310
310
|
const isRTL = () => document.documentElement.dir === 'rtl';
|
|
311
311
|
|
|
312
|
+
function isMobileDevice() {
|
|
313
|
+
const userAgent = navigator.userAgent;
|
|
314
|
+
const isMobileUA = /Android|iPhone|iPad|iPod/i.test(userAgent);
|
|
315
|
+
const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
316
|
+
const isSmallScreen = window.innerWidth < 768;
|
|
317
|
+
const isHighDPI = window.devicePixelRatio >= 2;
|
|
318
|
+
|
|
319
|
+
function detectIPadPro() {
|
|
320
|
+
const userAgent = navigator.userAgent;
|
|
321
|
+
const platform = navigator.platform;
|
|
322
|
+
|
|
323
|
+
const isIPad = /iPad/.test(userAgent) || (platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
|
324
|
+
|
|
325
|
+
if (!isIPad) return { isiPadPro: false };
|
|
326
|
+
|
|
327
|
+
const screenWidth = window.screen.width * window.devicePixelRatio;
|
|
328
|
+
const screenHeight = window.screen.height * window.devicePixelRatio;
|
|
329
|
+
|
|
330
|
+
const proResolutions = [
|
|
331
|
+
{ width: 2048, height: 2732 }, // 12.9"
|
|
332
|
+
{ width: 1668, height: 2388 }, // 11"
|
|
333
|
+
{ width: 1668, height: 2224 } // 10.5"
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
const isProResolution = proResolutions.some(res =>
|
|
337
|
+
(screenWidth === res.width && screenHeight === res.height) ||
|
|
338
|
+
(screenWidth === res.height && screenHeight === res.width)
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
return {
|
|
342
|
+
isiPadPro: isProResolution,
|
|
343
|
+
screenWidth: screenWidth,
|
|
344
|
+
screenHeight: screenHeight,
|
|
345
|
+
userAgent: userAgent,
|
|
346
|
+
platform: platform
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return isMobileUA || (isTouchDevice && isSmallScreen && isHighDPI) || detectIPadPro().isiPadPro;
|
|
351
|
+
}
|
|
352
|
+
|
|
312
353
|
// экспорт
|
|
313
354
|
export {
|
|
314
355
|
getDeepestLastChild,
|
|
@@ -331,4 +372,5 @@ export {
|
|
|
331
372
|
getNextActiveElement,
|
|
332
373
|
getTransitionDurationFromElement,
|
|
333
374
|
triggerTransitionEnd,
|
|
375
|
+
isMobileDevice
|
|
334
376
|
};
|