vgapp 0.6.0 → 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 +1 -4
- package/app/modules/base-module.js +32 -1
- package/app/modules/vgdropdown/js/vgdropdown.js +5 -12
- package/app/modules/vgdropdown/scss/vgdropdown.scss +31 -2
- package/app/modules/vgnav/js/vgnav.js +1 -3
- package/app/modules/vgnav/scss/_placement.scss +46 -6
- package/app/utils/js/components/placement.js +40 -15
- package/app/utils/js/dom/manipulator.js +29 -1
- package/build/vgapp.css +2 -1507
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +2 -30
- package/package.json +1 -1
- package/app/modules/vgnav/!old/!vgnav.js +0 -510
- package/app/modules/vgnav/!old/scss/_breakpoints.scss +0 -127
- package/app/modules/vgnav/!old/scss/_hamburger.scss +0 -62
- package/app/modules/vgnav/!old/scss/_placement.scss +0 -70
- package/app/modules/vgnav/!old/scss/_toggle.scss +0 -20
- package/app/modules/vgnav/!old/scss/_variables.scss +0 -70
- package/app/modules/vgnav/!old/scss/vgnav.scss +0 -164
package/CHANGELOG.md
CHANGED
|
@@ -103,7 +103,38 @@ class BaseModule {
|
|
|
103
103
|
const isSmallScreen = window.innerWidth < 768;
|
|
104
104
|
const isHighDPI = window.devicePixelRatio >= 2;
|
|
105
105
|
|
|
106
|
-
|
|
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;
|
|
107
138
|
}
|
|
108
139
|
|
|
109
140
|
static getInstance(element) {
|
|
@@ -35,7 +35,7 @@ class VGDropdown extends BaseModule {
|
|
|
35
35
|
overflow: false,
|
|
36
36
|
keyboard: false,
|
|
37
37
|
placement: 'bottom',
|
|
38
|
-
timeoutAnimation:
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
198
|
-
_this._drop.style.top = placement.top + 'px';
|
|
191
|
+
$placement._setPlacement();
|
|
199
192
|
}
|
|
200
193
|
|
|
201
194
|
if (_this._params.offset) {
|
|
@@ -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 {
|
|
@@ -359,9 +359,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
|
|
|
359
359
|
execute(instance._params.callbacks.afterClick, [instance, event, this]);
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
if (instance._params.hover)
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
362
|
+
if (instance._params.hover && !instance.isMobileDevice()) return;
|
|
365
363
|
|
|
366
364
|
event.preventDefault();
|
|
367
365
|
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
right: 0;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
&.top, .top {
|
|
16
|
+
top: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.bottom, .bottom {
|
|
20
|
+
bottom: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
.dropdown {
|
|
16
24
|
ul.left {
|
|
17
25
|
left: 100%;
|
|
@@ -20,6 +28,14 @@
|
|
|
20
28
|
ul.right {
|
|
21
29
|
right: 100%;
|
|
22
30
|
}
|
|
31
|
+
|
|
32
|
+
ul.top {
|
|
33
|
+
top: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ul.bottom {
|
|
37
|
+
bottom: 100%;
|
|
38
|
+
}
|
|
23
39
|
}
|
|
24
40
|
}
|
|
25
41
|
}
|
|
@@ -32,8 +48,6 @@
|
|
|
32
48
|
|
|
33
49
|
.dropdown {
|
|
34
50
|
> ul {
|
|
35
|
-
top: 100%;
|
|
36
|
-
|
|
37
51
|
&.left, .left {
|
|
38
52
|
left: 100%;
|
|
39
53
|
}
|
|
@@ -42,14 +56,34 @@
|
|
|
42
56
|
right: 100%;
|
|
43
57
|
}
|
|
44
58
|
|
|
59
|
+
&.top, .top {
|
|
60
|
+
top: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&.bottom, .bottom {
|
|
64
|
+
bottom: 100%;
|
|
65
|
+
}
|
|
66
|
+
|
|
45
67
|
&.fade {
|
|
46
|
-
top
|
|
68
|
+
&.top {
|
|
69
|
+
top: 0;
|
|
70
|
+
}
|
|
71
|
+
&.bottom {
|
|
72
|
+
bottom: 0;
|
|
73
|
+
}
|
|
47
74
|
}
|
|
48
75
|
}
|
|
49
76
|
|
|
50
77
|
&.show {
|
|
51
|
-
|
|
52
|
-
|
|
78
|
+
&.top {
|
|
79
|
+
> ul {
|
|
80
|
+
top: 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
&.bottom {
|
|
84
|
+
> ul {
|
|
85
|
+
bottom: 0;
|
|
86
|
+
}
|
|
53
87
|
}
|
|
54
88
|
}
|
|
55
89
|
}
|
|
@@ -62,7 +96,13 @@
|
|
|
62
96
|
top: 100%;
|
|
63
97
|
|
|
64
98
|
&.fade {
|
|
65
|
-
top
|
|
99
|
+
&.top {
|
|
100
|
+
top: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.bottom {
|
|
104
|
+
bottom: 0;
|
|
105
|
+
}
|
|
66
106
|
}
|
|
67
107
|
}
|
|
68
108
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {mergeDeepObject, normalizeData} from "../functions";
|
|
2
|
-
import
|
|
2
|
+
import {Classes} from "../dom/manipulator";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Класс Placement, определяет и устанавливает местоположение элемента на странице.
|
|
6
6
|
* TODO класс не дописан, не определяет сверху и снизу
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
const CLASS_NAME_RIGHT
|
|
10
|
-
const CLASS_NAME_LEFT
|
|
9
|
+
const CLASS_NAME_RIGHT = 'right';
|
|
10
|
+
const CLASS_NAME_LEFT = 'left';
|
|
11
|
+
const CLASS_NAME_TOP = 'top';
|
|
12
|
+
const CLASS_NAME_BOTTOM = 'bottom';
|
|
11
13
|
|
|
12
14
|
class Placement {
|
|
13
15
|
constructor(arg = {}) {
|
|
@@ -21,6 +23,8 @@ class Placement {
|
|
|
21
23
|
|
|
22
24
|
this._element = null;
|
|
23
25
|
this.element = this.params.element;
|
|
26
|
+
|
|
27
|
+
if (!this.drop) return false;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
get drop() {
|
|
@@ -47,13 +51,28 @@ class Placement {
|
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
_setPlacement() {
|
|
50
|
-
this.drop
|
|
51
|
-
this.drop.classList.remove(CLASS_NAME_LEFT);
|
|
54
|
+
let rect = this._isElementInViewport(this.drop);
|
|
52
55
|
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if (!rect.isView) {
|
|
57
|
+
if (!rect.isViewRight) {
|
|
58
|
+
Classes.remove(this.drop, CLASS_NAME_LEFT);
|
|
59
|
+
Classes.add(this.drop, CLASS_NAME_RIGHT);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!rect.isViewLeft) {
|
|
63
|
+
Classes.remove(this.drop, CLASS_NAME_RIGHT);
|
|
64
|
+
Classes.add(this.drop, CLASS_NAME_LEFT);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!rect.isViewTop) {
|
|
68
|
+
Classes.remove(this.drop, CLASS_NAME_BOTTOM);
|
|
69
|
+
Classes.add(this.drop, CLASS_NAME_TOP);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!rect.isViewBottom) {
|
|
73
|
+
Classes.remove(this.drop, CLASS_NAME_TOP);
|
|
74
|
+
Classes.add(this.drop, CLASS_NAME_BOTTOM);
|
|
75
|
+
}
|
|
57
76
|
}
|
|
58
77
|
}
|
|
59
78
|
|
|
@@ -104,12 +123,18 @@ class Placement {
|
|
|
104
123
|
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
105
124
|
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
106
125
|
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
return {
|
|
127
|
+
isView: (
|
|
128
|
+
rect.top >= 0 &&
|
|
129
|
+
rect.left >= 0 &&
|
|
130
|
+
rect.bottom <= viewportHeight &&
|
|
131
|
+
rect.right <= viewportWidth
|
|
132
|
+
),
|
|
133
|
+
isViewRight: rect.right <= viewportWidth,
|
|
134
|
+
isViewLeft: rect.left >= 0,
|
|
135
|
+
isViewTop: rect.top >= 0,
|
|
136
|
+
isViewBottom: rect.bottom <= viewportHeight,
|
|
137
|
+
};
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
|
|
@@ -69,4 +69,32 @@ const Manipulator = {
|
|
|
69
69
|
},
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
let Classes = {
|
|
73
|
+
remove(element, className) {
|
|
74
|
+
if (className && element) {
|
|
75
|
+
if (typeof className === 'string') {
|
|
76
|
+
className = className.split(' ');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
element.classList.remove(...className);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
add(element, className, isString = false) {
|
|
84
|
+
if (className) {
|
|
85
|
+
if (typeof className === 'string') {
|
|
86
|
+
className = className.split(' ');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (isString) {
|
|
90
|
+
return '' + className.join(' ');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (element) {
|
|
94
|
+
element.classList.add(...className);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export {Manipulator, Classes}
|