quasar 2.11.3 → 2.11.5
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/dist/icon-set/bootstrap-icons.umd.prod.js +1 -1
- package/dist/icon-set/eva-icons.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v5-pro.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v5.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v6-pro.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v6.umd.prod.js +1 -1
- package/dist/icon-set/ionicons-v4.umd.prod.js +1 -1
- package/dist/icon-set/line-awesome.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-outlined.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-round.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-sharp.umd.prod.js +1 -1
- package/dist/icon-set/material-icons.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-outlined.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-rounded.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-sharp.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v3.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v4.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v5.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v6.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v7.umd.prod.js +1 -1
- package/dist/icon-set/svg-bootstrap-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-eva-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-fontawesome-v5.umd.prod.js +1 -1
- package/dist/icon-set/svg-fontawesome-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v4.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v5.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-line-awesome.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-outlined.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-round.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-sharp.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-outlined.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-rounded.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-sharp.umd.prod.js +1 -1
- package/dist/icon-set/svg-mdi-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-mdi-v7.umd.prod.js +1 -1
- package/dist/icon-set/svg-themify.umd.prod.js +1 -1
- package/dist/icon-set/themify.umd.prod.js +1 -1
- package/dist/lang/ar-TN.umd.prod.js +1 -1
- package/dist/lang/ar.umd.prod.js +1 -1
- package/dist/lang/az-Latn.umd.prod.js +1 -1
- package/dist/lang/bg.umd.prod.js +1 -1
- package/dist/lang/bn.umd.prod.js +1 -1
- package/dist/lang/ca.umd.prod.js +1 -1
- package/dist/lang/cs.umd.prod.js +1 -1
- package/dist/lang/da.umd.prod.js +1 -1
- package/dist/lang/de.umd.prod.js +1 -1
- package/dist/lang/el.umd.prod.js +1 -1
- package/dist/lang/en-GB.umd.prod.js +1 -1
- package/dist/lang/en-US.umd.prod.js +1 -1
- package/dist/lang/eo.umd.prod.js +1 -1
- package/dist/lang/es.umd.prod.js +1 -1
- package/dist/lang/et.umd.prod.js +1 -1
- package/dist/lang/eu.umd.prod.js +1 -1
- package/dist/lang/fa-IR.umd.prod.js +1 -1
- package/dist/lang/fa.umd.prod.js +1 -1
- package/dist/lang/fi.umd.prod.js +1 -1
- package/dist/lang/fr.umd.prod.js +1 -1
- package/dist/lang/gn.umd.prod.js +1 -1
- package/dist/lang/he.umd.prod.js +1 -1
- package/dist/lang/hr.umd.prod.js +1 -1
- package/dist/lang/hu.umd.prod.js +1 -1
- package/dist/lang/id.umd.prod.js +1 -1
- package/dist/lang/is.umd.prod.js +1 -1
- package/dist/lang/it.umd.prod.js +1 -1
- package/dist/lang/ja.umd.prod.js +1 -1
- package/dist/lang/kk.umd.prod.js +1 -1
- package/dist/lang/km.umd.prod.js +1 -1
- package/dist/lang/ko-KR.umd.prod.js +1 -1
- package/dist/lang/kur-CKB.umd.prod.js +1 -1
- package/dist/lang/lt.umd.prod.js +1 -1
- package/dist/lang/lu.umd.prod.js +1 -1
- package/dist/lang/lv.umd.prod.js +1 -1
- package/dist/lang/ml.umd.prod.js +1 -1
- package/dist/lang/mm.umd.prod.js +1 -1
- package/dist/lang/ms.umd.prod.js +1 -1
- package/dist/lang/my.umd.prod.js +1 -1
- package/dist/lang/nb-NO.umd.prod.js +1 -1
- package/dist/lang/nl.umd.prod.js +1 -1
- package/dist/lang/pl.umd.prod.js +1 -1
- package/dist/lang/pt-BR.umd.prod.js +1 -1
- package/dist/lang/pt.umd.prod.js +1 -1
- package/dist/lang/ro.umd.prod.js +1 -1
- package/dist/lang/ru.umd.prod.js +1 -1
- package/dist/lang/sk.umd.prod.js +1 -1
- package/dist/lang/sl.umd.prod.js +1 -1
- package/dist/lang/sm.umd.prod.js +1 -1
- package/dist/lang/sr-CYR.umd.prod.js +1 -1
- package/dist/lang/sr.umd.prod.js +1 -1
- package/dist/lang/sv.umd.prod.js +1 -1
- package/dist/lang/ta.umd.prod.js +1 -1
- package/dist/lang/th.umd.prod.js +1 -1
- package/dist/lang/tr.umd.prod.js +1 -1
- package/dist/lang/ug.umd.prod.js +1 -1
- package/dist/lang/uk.umd.prod.js +1 -1
- package/dist/lang/uz-Cyrl.umd.prod.js +1 -1
- package/dist/lang/uz-Latn.umd.prod.js +1 -1
- package/dist/lang/vi.umd.prod.js +1 -1
- package/dist/lang/zh-CN.umd.prod.js +1 -1
- package/dist/lang/zh-TW.umd.prod.js +1 -1
- package/dist/quasar.cjs.prod.js +2 -2
- package/dist/quasar.esm.js +445 -196
- package/dist/quasar.esm.prod.js +2 -2
- package/dist/quasar.sass +1 -1
- package/dist/quasar.umd.js +445 -196
- package/dist/quasar.umd.prod.js +2 -2
- package/dist/web-types/web-types.json +1 -1
- package/package.json +1 -1
- package/src/components/ajax-bar/QAjaxBar.js +13 -5
- package/src/components/btn/QBtn.js +3 -2
- package/src/components/carousel/QCarousel.js +17 -10
- package/src/components/dialog/QDialog.js +10 -5
- package/src/components/drawer/QDrawer.js +8 -3
- package/src/components/img/QImg.js +25 -11
- package/src/components/infinite-scroll/QInfiniteScroll.js +26 -4
- package/src/components/input/QInput.js +14 -4
- package/src/components/layout/QLayout.js +5 -5
- package/src/components/menu/QMenu.js +1 -1
- package/src/components/pull-to-refresh/QPullToRefresh.js +5 -4
- package/src/components/rating/QRating.js +3 -3
- package/src/components/resize-observer/QResizeObserver.js +9 -4
- package/src/components/scroll-area/QScrollArea.js +8 -8
- package/src/components/select/QSelect.js +19 -8
- package/src/components/slide-item/QSlideItem.js +4 -2
- package/src/components/slide-transition/QSlideTransition.js +17 -3
- package/src/components/tabs/QTabs.js +12 -5
- package/src/components/tooltip/QTooltip.js +1 -1
- package/src/components/virtual-scroll/use-virtual-scroll.js +5 -1
- package/src/composables/private/use-anchor.js +8 -3
- package/src/composables/private/use-field.js +10 -4
- package/src/composables/private/use-portal.js +3 -3
- package/src/composables/private/use-timeout.js +6 -3
- package/src/directives/TouchHold.js +9 -4
- package/src/directives/TouchRepeat.js +10 -3
- package/src/plugins/Loading.js +16 -11
- package/src/plugins/Meta.js +4 -2
- package/src/plugins/Notify.js +13 -3
- package/src/utils/copy-to-clipboard.js +8 -0
- package/src/utils/debounce.js +9 -6
- package/src/utils/is.js +11 -6
- package/src/utils/morph.js +7 -6
- package/src/utils/prevent-scroll.js +14 -7
- package/src/utils/private/click-outside.js +10 -3
- package/src/utils/private/global-dialog.js +1 -1
- package/src/utils/private/global-nodes.js +44 -13
- package/src/utils/private/position-engine.js +67 -25
package/src/utils/is.js
CHANGED
|
@@ -32,20 +32,23 @@ export function isDeepEqual (a, b) {
|
|
|
32
32
|
return false
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
let iter = a.entries()
|
|
36
|
+
|
|
37
|
+
i = iter.next()
|
|
36
38
|
while (i.done !== true) {
|
|
37
39
|
if (b.has(i.value[ 0 ]) !== true) {
|
|
38
40
|
return false
|
|
39
41
|
}
|
|
40
|
-
i =
|
|
42
|
+
i = iter.next()
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
iter = a.entries()
|
|
46
|
+
i = iter.next()
|
|
44
47
|
while (i.done !== true) {
|
|
45
48
|
if (isDeepEqual(i.value[ 1 ], b.get(i.value[ 0 ])) !== true) {
|
|
46
49
|
return false
|
|
47
50
|
}
|
|
48
|
-
i =
|
|
51
|
+
i = iter.next()
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
return true
|
|
@@ -56,12 +59,14 @@ export function isDeepEqual (a, b) {
|
|
|
56
59
|
return false
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
const iter = a.entries()
|
|
63
|
+
|
|
64
|
+
i = iter.next()
|
|
60
65
|
while (i.done !== true) {
|
|
61
66
|
if (b.has(i.value[ 0 ]) !== true) {
|
|
62
67
|
return false
|
|
63
68
|
}
|
|
64
|
-
i =
|
|
69
|
+
i = iter.next()
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
return true
|
package/src/utils/morph.js
CHANGED
|
@@ -950,12 +950,11 @@ export default function morph (_options) {
|
|
|
950
950
|
: (
|
|
951
951
|
options.waitFor === 'transitionend'
|
|
952
952
|
? new Promise(resolve => {
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
clearTimeout(timer)
|
|
953
|
+
const endFn = () => {
|
|
954
|
+
if (timer !== null) {
|
|
955
|
+
clearTimeout(timer)
|
|
956
|
+
timer = null
|
|
957
|
+
}
|
|
959
958
|
|
|
960
959
|
if (elTo) {
|
|
961
960
|
elTo.removeEventListener('transitionend', endFn)
|
|
@@ -965,6 +964,8 @@ export default function morph (_options) {
|
|
|
965
964
|
resolve()
|
|
966
965
|
}
|
|
967
966
|
|
|
967
|
+
let timer = setTimeout(endFn, 400)
|
|
968
|
+
|
|
968
969
|
elTo.addEventListener('transitionend', endFn)
|
|
969
970
|
elTo.addEventListener('transitioncancel', endFn)
|
|
970
971
|
})
|
|
@@ -10,7 +10,8 @@ let
|
|
|
10
10
|
vpPendingUpdate = false,
|
|
11
11
|
bodyLeft,
|
|
12
12
|
bodyTop,
|
|
13
|
-
|
|
13
|
+
href,
|
|
14
|
+
closeTimer = null
|
|
14
15
|
|
|
15
16
|
function onWheel (e) {
|
|
16
17
|
if (shouldPreventScroll(e)) {
|
|
@@ -96,6 +97,8 @@ function apply (action) {
|
|
|
96
97
|
bodyLeft = body.style.left
|
|
97
98
|
bodyTop = body.style.top
|
|
98
99
|
|
|
100
|
+
href = window.location.href
|
|
101
|
+
|
|
99
102
|
body.style.left = `-${ scrollPositionX }px`
|
|
100
103
|
body.style.top = `-${ scrollPositionY }px`
|
|
101
104
|
|
|
@@ -108,6 +111,7 @@ function apply (action) {
|
|
|
108
111
|
|
|
109
112
|
body.classList.add('q-body--prevent-scroll')
|
|
110
113
|
document.qScrollPrevented = true
|
|
114
|
+
|
|
111
115
|
if (client.is.ios === true) {
|
|
112
116
|
if (hasViewport === true) {
|
|
113
117
|
window.scrollTo(0, 0)
|
|
@@ -146,7 +150,11 @@ function apply (action) {
|
|
|
146
150
|
body.style.left = bodyLeft
|
|
147
151
|
body.style.top = bodyTop
|
|
148
152
|
|
|
149
|
-
|
|
153
|
+
// scroll back only if route has not changed
|
|
154
|
+
if (window.location.href === href) {
|
|
155
|
+
window.scrollTo(scrollPositionX, scrollPositionY)
|
|
156
|
+
}
|
|
157
|
+
|
|
150
158
|
maxScrollTop = void 0
|
|
151
159
|
}
|
|
152
160
|
}
|
|
@@ -157,9 +165,9 @@ export default function (state) {
|
|
|
157
165
|
if (state === true) {
|
|
158
166
|
registered++
|
|
159
167
|
|
|
160
|
-
if (closeTimer !==
|
|
168
|
+
if (closeTimer !== null) {
|
|
161
169
|
clearTimeout(closeTimer)
|
|
162
|
-
closeTimer =
|
|
170
|
+
closeTimer = null
|
|
163
171
|
return
|
|
164
172
|
}
|
|
165
173
|
|
|
@@ -181,11 +189,10 @@ export default function (state) {
|
|
|
181
189
|
action = 'remove'
|
|
182
190
|
|
|
183
191
|
if (client.is.ios === true && client.is.nativeMobile === true) {
|
|
184
|
-
clearTimeout(closeTimer)
|
|
185
|
-
|
|
192
|
+
closeTimer !== null && clearTimeout(closeTimer)
|
|
186
193
|
closeTimer = setTimeout(() => {
|
|
187
194
|
apply(action)
|
|
188
|
-
closeTimer =
|
|
195
|
+
closeTimer = null
|
|
189
196
|
}, 100)
|
|
190
197
|
return
|
|
191
198
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { listenOpts } from '../event.js'
|
|
2
2
|
import { portalProxyList } from '../private/portal.js'
|
|
3
3
|
|
|
4
|
-
let timer
|
|
4
|
+
let timer = null
|
|
5
5
|
|
|
6
6
|
const
|
|
7
7
|
{ notPassiveCapture } = listenOpts,
|
|
8
8
|
registeredList = []
|
|
9
9
|
|
|
10
10
|
function globalHandler (evt) {
|
|
11
|
-
|
|
11
|
+
if (timer !== null) {
|
|
12
|
+
clearTimeout(timer)
|
|
13
|
+
timer = null
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
const target = evt.target
|
|
14
17
|
|
|
@@ -81,7 +84,11 @@ export function removeClickOutside (clickOutsideProps) {
|
|
|
81
84
|
registeredList.splice(index, 1)
|
|
82
85
|
|
|
83
86
|
if (registeredList.length === 0) {
|
|
84
|
-
|
|
87
|
+
if (timer !== null) {
|
|
88
|
+
clearTimeout(timer)
|
|
89
|
+
timer = null
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
document.removeEventListener('mousedown', globalHandler, notPassiveCapture)
|
|
86
93
|
document.removeEventListener('touchstart', globalHandler, notPassiveCapture)
|
|
87
94
|
}
|
|
@@ -54,7 +54,7 @@ export default function (DefaultComponent, supportsCustomComponent, parentApp) {
|
|
|
54
54
|
|
|
55
55
|
let vm, emittedOK = false
|
|
56
56
|
const dialogRef = ref(null)
|
|
57
|
-
const el = createGlobalNode()
|
|
57
|
+
const el = createGlobalNode(false, 'dialog')
|
|
58
58
|
|
|
59
59
|
const applyState = cmd => {
|
|
60
60
|
if (dialogRef.value !== null && dialogRef.value[ cmd ] !== void 0) {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { globalConfig } from './global-config.js'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const nodesList = []
|
|
4
|
+
const portalTypeList = []
|
|
5
|
+
|
|
6
|
+
let portalIndex = 1
|
|
4
7
|
let target = __QUASAR_SSR_SERVER__
|
|
5
8
|
? void 0
|
|
6
9
|
: document.body
|
|
7
10
|
|
|
8
|
-
export function createGlobalNode (id) {
|
|
11
|
+
export function createGlobalNode (id, portalType) {
|
|
9
12
|
const el = document.createElement('div')
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
el.id = portalType !== void 0
|
|
15
|
+
? `q-portal--${ portalType }--${ portalIndex++ }`
|
|
16
|
+
: id
|
|
14
17
|
|
|
15
18
|
if (globalConfig.globalNodes !== void 0) {
|
|
16
19
|
const cls = globalConfig.globalNodes.class
|
|
@@ -20,24 +23,52 @@ export function createGlobalNode (id) {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
target.appendChild(el)
|
|
23
|
-
|
|
26
|
+
nodesList.push(el)
|
|
27
|
+
portalTypeList.push(portalType)
|
|
24
28
|
|
|
25
29
|
return el
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export function removeGlobalNode (el) {
|
|
29
|
-
|
|
33
|
+
const nodeIndex = nodesList.indexOf(el)
|
|
34
|
+
|
|
35
|
+
nodesList.splice(nodeIndex, 1)
|
|
36
|
+
portalTypeList.splice(nodeIndex, 1)
|
|
37
|
+
|
|
30
38
|
el.remove()
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
export function changeGlobalNodesTarget (
|
|
34
|
-
if (
|
|
35
|
-
|
|
41
|
+
export function changeGlobalNodesTarget (newTarget) {
|
|
42
|
+
if (newTarget === target) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
target = newTarget
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
if (
|
|
49
|
+
target === document.body
|
|
50
|
+
// or we have less than 2 dialogs:
|
|
51
|
+
|| portalTypeList.reduce((acc, type) => (type === 'dialog' ? acc + 1 : acc), 0) < 2
|
|
52
|
+
) {
|
|
53
|
+
nodesList.forEach(node => {
|
|
54
|
+
if (node.contains(target) === false) {
|
|
55
|
+
target.appendChild(node)
|
|
40
56
|
}
|
|
41
57
|
})
|
|
58
|
+
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const lastDialogIndex = portalTypeList.lastIndexOf('dialog')
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < nodesList.length; i++) {
|
|
65
|
+
const el = nodesList[ i ]
|
|
66
|
+
|
|
67
|
+
if (
|
|
68
|
+
(i === lastDialogIndex || portalTypeList[ i ] !== 'dialog')
|
|
69
|
+
&& el.contains(target) === false
|
|
70
|
+
) {
|
|
71
|
+
target.appendChild(el)
|
|
72
|
+
}
|
|
42
73
|
}
|
|
43
74
|
}
|
|
@@ -62,17 +62,32 @@ export function getAnchorProps (el, offset) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return {
|
|
65
|
-
top,
|
|
66
|
-
left,
|
|
67
|
-
right,
|
|
68
|
-
bottom,
|
|
69
|
-
width,
|
|
70
|
-
height,
|
|
65
|
+
top, bottom, height,
|
|
66
|
+
left, right, width,
|
|
71
67
|
middle: left + (right - left) / 2,
|
|
72
68
|
center: top + (bottom - top) / 2
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
|
|
72
|
+
function getAbsoluteAnchorProps (el, absoluteOffset, offset) {
|
|
73
|
+
let { top, left } = el.getBoundingClientRect()
|
|
74
|
+
|
|
75
|
+
top += absoluteOffset.top
|
|
76
|
+
left += absoluteOffset.left
|
|
77
|
+
|
|
78
|
+
if (offset !== void 0) {
|
|
79
|
+
top += offset[ 1 ]
|
|
80
|
+
left += offset[ 0 ]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
top, bottom: top + 1, height: 1,
|
|
85
|
+
left, right: left + 1, width: 1,
|
|
86
|
+
middle: left,
|
|
87
|
+
center: top
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
export function getTargetProps (el) {
|
|
77
92
|
return {
|
|
78
93
|
top: 0,
|
|
@@ -84,6 +99,13 @@ export function getTargetProps (el) {
|
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
|
|
102
|
+
function getTopLeftProps (anchorProps, targetProps, cfg) {
|
|
103
|
+
return {
|
|
104
|
+
top: anchorProps[ cfg.anchorOrigin.vertical ] - targetProps[ cfg.selfOrigin.vertical ],
|
|
105
|
+
left: anchorProps[ cfg.anchorOrigin.horizontal ] - targetProps[ cfg.selfOrigin.horizontal ]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
87
109
|
// cfg: { el, anchorEl, anchorOrigin, selfOrigin, offset, absoluteOffset, cover, fit, maxHeight, maxWidth }
|
|
88
110
|
export function setPosition (cfg) {
|
|
89
111
|
if (client.is.ios === true && window.visualViewport !== void 0) {
|
|
@@ -102,25 +124,15 @@ export function setPosition (cfg) {
|
|
|
102
124
|
}
|
|
103
125
|
}
|
|
104
126
|
|
|
105
|
-
let anchorProps
|
|
106
|
-
|
|
107
127
|
// scroll position might change
|
|
108
128
|
// if max-height/-width changes, so we
|
|
109
129
|
// need to restore it after we calculate
|
|
110
130
|
// the new positioning
|
|
111
131
|
const { scrollLeft, scrollTop } = cfg.el
|
|
112
132
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
else {
|
|
117
|
-
const
|
|
118
|
-
{ top: anchorTop, left: anchorLeft } = cfg.anchorEl.getBoundingClientRect(),
|
|
119
|
-
top = anchorTop + cfg.absoluteOffset.top,
|
|
120
|
-
left = anchorLeft + cfg.absoluteOffset.left
|
|
121
|
-
|
|
122
|
-
anchorProps = { top, left, width: 1, height: 1, right: left + 1, center: top, middle: left, bottom: top + 1 }
|
|
123
|
-
}
|
|
133
|
+
const anchorProps = cfg.absoluteOffset === void 0
|
|
134
|
+
? getAnchorProps(cfg.anchorEl, cfg.cover === true ? [ 0, 0 ] : cfg.offset)
|
|
135
|
+
: getAbsoluteAnchorProps(cfg.anchorEl, cfg.absoluteOffset, cfg.offset)
|
|
124
136
|
|
|
125
137
|
let elStyle = {
|
|
126
138
|
maxHeight: cfg.maxHeight,
|
|
@@ -137,14 +149,44 @@ export function setPosition (cfg) {
|
|
|
137
149
|
|
|
138
150
|
Object.assign(cfg.el.style, elStyle)
|
|
139
151
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
const targetProps = getTargetProps(cfg.el)
|
|
153
|
+
let props = getTopLeftProps(anchorProps, targetProps, cfg)
|
|
154
|
+
|
|
155
|
+
if (cfg.absoluteOffset === void 0 || cfg.offset === void 0) {
|
|
156
|
+
applyBoundaries(props, anchorProps, targetProps, cfg.anchorOrigin, cfg.selfOrigin)
|
|
157
|
+
}
|
|
158
|
+
else { // we have touch position or context menu with offset
|
|
159
|
+
const { top, left } = props // cache initial values
|
|
160
|
+
|
|
161
|
+
// apply initial boundaries
|
|
162
|
+
applyBoundaries(props, anchorProps, targetProps, cfg.anchorOrigin, cfg.selfOrigin)
|
|
163
|
+
|
|
164
|
+
let hasChanged = false
|
|
165
|
+
|
|
166
|
+
// did it flip vertically?
|
|
167
|
+
if (props.top !== top) {
|
|
168
|
+
hasChanged = true
|
|
169
|
+
const offsetY = 2 * cfg.offset[ 1 ]
|
|
170
|
+
anchorProps.center = anchorProps.top -= offsetY
|
|
171
|
+
anchorProps.bottom -= offsetY + 2
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// did it flip horizontally?
|
|
175
|
+
if (props.left !== left) {
|
|
176
|
+
hasChanged = true
|
|
177
|
+
const offsetX = 2 * cfg.offset[ 0 ]
|
|
178
|
+
anchorProps.middle = anchorProps.left -= offsetX
|
|
179
|
+
anchorProps.right -= offsetX + 2
|
|
145
180
|
}
|
|
146
181
|
|
|
147
|
-
|
|
182
|
+
if (hasChanged === true) {
|
|
183
|
+
// re-calculate props with the new anchor
|
|
184
|
+
props = getTopLeftProps(anchorProps, targetProps, cfg)
|
|
185
|
+
|
|
186
|
+
// and re-apply boundaries
|
|
187
|
+
applyBoundaries(props, anchorProps, targetProps, cfg.anchorOrigin, cfg.selfOrigin)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
148
190
|
|
|
149
191
|
elStyle = {
|
|
150
192
|
top: props.top + 'px',
|