vgapp 0.8.4 → 0.8.6
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/vgnav/js/vgnav.js +11 -3
- package/app/modules/vgsidebar/js/vgsidebar.js +0 -18
- package/app/utils/js/components/backdrop.js +1 -1
- package/app/utils/js/components/scrollbar.js +11 -11
- 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) => {
|
|
@@ -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
|
|
|
@@ -280,24 +280,6 @@ class VGSidebar extends BaseModule {
|
|
|
280
280
|
}
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Инициализирует поведение закрытия по клику вне (через `dismissTrigger`).
|
|
286
|
-
* @private
|
|
287
|
-
*/
|
|
288
|
-
_dismissElement() {
|
|
289
|
-
dismissTrigger(this);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Заглушка для возможной AJAX-логики. Может быть переопределена.
|
|
294
|
-
* @param {Function} callback - Колбэк после загрузки.
|
|
295
|
-
* @private
|
|
296
|
-
*/
|
|
297
|
-
_route(callback) {
|
|
298
|
-
// Здесь может быть реализация AJAX-загрузки
|
|
299
|
-
callback(true, null);
|
|
300
|
-
}
|
|
301
283
|
}
|
|
302
284
|
|
|
303
285
|
// Автоматическая инициализация по data-атрибутам
|
|
@@ -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() {
|
|
@@ -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
|
|
@@ -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
|
};
|