material 0.8.6 → 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/package.json +1 -1
- package/src/mixin/position.js +4 -16
package/package.json
CHANGED
package/src/mixin/position.js
CHANGED
|
@@ -5,7 +5,6 @@ export default {
|
|
|
5
5
|
const { offsetX = 0, offsetY = 0, align = 'center', vAlign = 'middle' } = position
|
|
6
6
|
|
|
7
7
|
const name = this.constructor.name
|
|
8
|
-
console.log('constructor', name)
|
|
9
8
|
|
|
10
9
|
if (!target) return
|
|
11
10
|
|
|
@@ -13,15 +12,8 @@ export default {
|
|
|
13
12
|
const screen = this.element.parentNode.getBoundingClientRect()
|
|
14
13
|
const element = this.element.getBoundingClientRect()
|
|
15
14
|
|
|
16
|
-
console.log('caller', caller)
|
|
17
|
-
console.log('screen', screen)
|
|
18
|
-
console.log('element', element)
|
|
19
|
-
|
|
20
15
|
let left, top
|
|
21
16
|
|
|
22
|
-
console.log('align', align)
|
|
23
|
-
console.log('target left', caller.left)
|
|
24
|
-
|
|
25
17
|
switch (align) {
|
|
26
18
|
case 'left':
|
|
27
19
|
left = caller.left + caller.width
|
|
@@ -40,13 +32,15 @@ export default {
|
|
|
40
32
|
left = caller.left + (caller.width / 2) - (element.width / 2)
|
|
41
33
|
}
|
|
42
34
|
|
|
35
|
+
// ensure that the element remains within the limits of its container
|
|
36
|
+
|
|
43
37
|
if (left < 0) left = offsetX
|
|
44
38
|
|
|
45
39
|
if (left + element.width + offsetX > screen.width) {
|
|
46
|
-
left =
|
|
40
|
+
left = screen.width - element.width - offsetX
|
|
47
41
|
}
|
|
48
42
|
|
|
49
|
-
console.log('left', left)
|
|
43
|
+
// console.log('left', left)
|
|
50
44
|
|
|
51
45
|
// left = Math.max(offsetX, Math.min(left, screen.width - element.width - offsetX))
|
|
52
46
|
|
|
@@ -77,12 +71,6 @@ export default {
|
|
|
77
71
|
top = caller.top + scrollY + (caller.height / 2) - (element.height / 2)
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
// if (this.options.class !== 'menu') {
|
|
81
|
-
// top = Math.max(offsetY, Math.min(top, screen.height - element.height - offsetY))
|
|
82
|
-
// }
|
|
83
|
-
|
|
84
|
-
console.log('top', top)
|
|
85
|
-
|
|
86
74
|
this.element.style.left = `${left}px`
|
|
87
75
|
this.element.style.top = `${top}px`
|
|
88
76
|
|