kui-vue 3.3.11 → 3.4.0

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.
Files changed (66) hide show
  1. package/components/_tool/clone.js +1 -2
  2. package/components/_tool/transfer.js +5 -5
  3. package/components/_tool/utils.js +2 -137
  4. package/components/alert/styles/index.less +2 -2
  5. package/components/avatar/AvatarGroup.jsx +2 -2
  6. package/components/backtop/styles/index.less +44 -47
  7. package/components/base/drop.jsx +231 -17
  8. package/components/base/pop.jsx +35 -21
  9. package/components/button/button.jsx +5 -11
  10. package/components/button/index.js +1 -8
  11. package/components/collapse/styles/index.less +3 -16
  12. package/components/colorPicker/colorpicker.jsx +4 -3
  13. package/components/colorPicker/styles/index.less +22 -43
  14. package/components/datePicker/datecalendar.jsx +1 -1
  15. package/components/datePicker/datepicker.jsx +5 -2
  16. package/components/datePicker/styles/datepicker.less +4 -14
  17. package/components/drawer/drawer.jsx +1 -1
  18. package/components/dropdown/demo/base.md +1 -1
  19. package/components/dropdown/demo/rightmenu.md +5 -5
  20. package/components/dropdown/dropdown.jsx +11 -3
  21. package/components/dropdown/styles/index.less +35 -13
  22. package/components/form/demo/align.md +1 -1
  23. package/components/form/demo/base.md +1 -1
  24. package/components/form/demo/dynamicvalid.md +1 -1
  25. package/components/form/demo/length.md +2 -2
  26. package/components/form/demo/valid.md +2 -2
  27. package/components/form/form.jsx +1 -1
  28. package/components/form/styles/index.less +3 -14
  29. package/components/fragment/component.js +98 -0
  30. package/components/fragment/frag.js +362 -0
  31. package/components/fragment/fragment.js +19 -0
  32. package/components/fragment/index.js +104 -0
  33. package/components/fragment/ssr.js +4 -0
  34. package/components/icon/demo/search.vue +1 -1
  35. package/components/image/styles/index.less +41 -17
  36. package/components/index.js +2 -2
  37. package/components/input/styles/index.less +2 -2
  38. package/components/menu/menuitem.jsx +12 -7
  39. package/components/menu/styles/index.less +190 -203
  40. package/components/menu/submenu.jsx +106 -37
  41. package/components/message/styles/index.less +11 -14
  42. package/components/modal/index.js +1 -1
  43. package/components/modal/modal.jsx +2 -2
  44. package/components/modal/styles/index.less +227 -221
  45. package/components/notice/styles/index.less +19 -5
  46. package/components/popconfirm/styles/index.less +33 -14
  47. package/components/poptip/demo/closeinside.md +1 -1
  48. package/components/poptip/styles/index.less +3 -14
  49. package/components/radio/button.jsx +1 -1
  50. package/components/rate/styles/index.less +9 -1
  51. package/components/select/demo/base.md +1 -1
  52. package/components/select/demo/multiple.md +1 -1
  53. package/components/select/demo/theme.md +11 -13
  54. package/components/select/select.jsx +64 -34
  55. package/components/select/styles/index.less +143 -149
  56. package/components/table/table.jsx +1 -1
  57. package/components/tabs/styles/index.less +3 -2
  58. package/components/tag/styles/index.less +3 -15
  59. package/components/tooltip/styles/index.less +48 -17
  60. package/components/tooltip/tooltip.jsx +3 -3
  61. package/components/tree/node.jsx +1 -1
  62. package/dist/k-ui.css +2 -2
  63. package/dist/k-ui.js +2 -2
  64. package/package.json +4 -4
  65. package/components/menu/styles/dropmenu.less +0 -119
  66. /package/{README.md → readme.md} +0 -0
@@ -55,6 +55,7 @@ function extractData(vnode, isComp) {
55
55
  return data
56
56
  }
57
57
 
58
+
58
59
  export default function cloneVNode(vnode, options = {}, child) {
59
60
  if (!vnode) return vnode
60
61
  // use the context that the original vnode was created in.
@@ -93,10 +94,8 @@ export default function cloneVNode(vnode, options = {}, child) {
93
94
  }
94
95
  }
95
96
  data.on = { ...oEven, ...nEven }
96
- // console.log(data, oEven, nEven)
97
97
  const tag = isComp
98
98
  ? vnode.componentOptions.Ctor
99
99
  : vnode.tag
100
- // const childNodes = children ? children.map(c => cloneVNode(c)) : undefined
101
100
  return h(tag, data, children)
102
101
  }
@@ -7,7 +7,7 @@ export default {
7
7
  const parentNode = el.parentNode
8
8
  if (!parentNode) return false;
9
9
 
10
- const target = value === true ? document.body : value || document.body
10
+ const target = (value === true ? document.body : value) || document.body
11
11
  // let empty = document.createComment('')
12
12
 
13
13
  if (target != document.body) {
@@ -16,10 +16,10 @@ export default {
16
16
  } else {
17
17
 
18
18
  let box = document.createElement('div')
19
- box.style.top = 0
20
- box.style.left = 0
21
- box.style.width = '100%'
22
- box.style.position = 'absolute'
19
+ // box.style.top = 0
20
+ // box.style.left = 0
21
+ // box.style.width = '100%'
22
+ // box.style.position = 'absolute'
23
23
 
24
24
  // parentNode.replaceChild(empty, el)
25
25
 
@@ -1,6 +1,7 @@
1
1
  export function isEmptyNode(vnode = {}) {
2
2
  return !(vnode.eml || vnode.tag || (vnode.text && vnode.text.trim() !== ''))
3
3
  }
4
+
4
5
  export function getChild(child = [], name) {
5
6
  // return child.filter(c => !isEmptyNode(c, name) )
6
7
  return child.filter(c => {
@@ -63,7 +64,6 @@ export function getElementPos(element) {
63
64
  /*
64
65
  see: https://github.com/vuejs/vue/blob/dev/src/core/vdom/vnode.js
65
66
  */
66
-
67
67
  export function cloneVNode(vnode, options = {}, childs) {
68
68
  let { componentOptions, data = {}, children } = vnode
69
69
  if (childs && children) {
@@ -76,7 +76,7 @@ export function cloneVNode(vnode, options = {}, childs) {
76
76
  componentOptions.children = componentOptions.children.concat(childs)
77
77
  }
78
78
  }
79
- let ndata = JSON.parse(JSON.stringify(data))
79
+ // let ndata = JSON.parse(JSON.stringify(data))
80
80
  let { attrs = {}, on = {}, style = {} } = data
81
81
 
82
82
  data.attrs = Object.assign(attrs, options.attrs)
@@ -122,142 +122,7 @@ export function isVnode(element) {
122
122
  element.tag !== undefined
123
123
  );
124
124
  }
125
- export function getPosition(selection, picker, transfer, placement = 'bottom-left', callback) {
126
- let top = 0, left = 0, offset = 3;
127
- let origins = {
128
- top: 'center bottom', 'top-left': 'left bottom', 'top-right': 'right bottom',
129
- left: 'right center', 'left-top': 'right top', 'left-bottom': 'right bottom',
130
- right: 'left center', 'right-top': 'left top', 'right-bottom': 'left bottom',
131
- bottom: 'center top', 'bottom-left': 'left top', 'bottom-right': 'right top'
132
- }
133
-
134
- if (picker && selection) {
135
-
136
- let selectionRect = selection.getBoundingClientRect();
137
- let pickerHeight = picker.offsetHeight
138
- let pickerWidth = picker.offsetWidth
139
- let clientHeight = document.documentElement.clientHeight
140
- let clientWidth = document.documentElement.clientWidth
141
- let scrollTop = document.documentElement.scrollTop
142
- let scrollLeft = document.documentElement.scrollLeft
143
- //是否有足够的空间
144
- //底部
145
- let showInBottom = clientHeight - selectionRect.bottom > pickerHeight
146
- //上面
147
- let showInTop = selectionRect.top > pickerHeight
148
- //左边
149
- let showInLeft = selectionRect.left > pickerWidth
150
- //右边
151
- let showInRight = clientWidth - selectionRect.right > pickerWidth
152
-
153
- // console.log(showInRight, selectionRect.left > pickerWidth, selectionRect.right, pickerWidth)
154
- console.log('bottom:', showInBottom, 'top:', showInTop, 'left:', showInLeft, 'right:', showInRight)
155
- // console.log(placement, 'showInTop:', showInTop, 'showInBottom:', showInBottom, clientHeight, scrollTop, selectionRect.top, pickerHeight)
156
-
157
- let hasBottom = placement.slice(0, 6) == 'bottom'
158
- let hasTop = placement.slice(0, 3) == 'top'
159
- let hasLeft = placement.slice(0, 4) == 'left'
160
- let hasRight = placement.slice(0, 5) == 'right'
161
- // debugger
162
- if (hasBottom || hasTop) {
163
- if ((hasBottom && showInBottom) || (hasTop && !showInTop)) { //正常在底部显示
164
- if (transfer) {
165
- top = selectionRect.bottom + offset + scrollTop;
166
- left = selectionRect.left + scrollLeft
167
- // left = showInRight ? selectionRect.left + scrollLeft : selectionRect.right - pickerWidth + scrollLeft
168
- if (placement == 'bottom' || placement == 'top') {
169
- left = selectionRect.left - (pickerWidth - selectionRect.width) / 2 + scrollLeft
170
- }
171
- if (placement == 'bottom-right' || placement == 'top-right') {
172
- left = selectionRect.left - (pickerWidth - selectionRect.width) + scrollLeft
173
- }
174
- if (hasTop) {
175
- placement = placement.replace('top', 'bottom')
176
- }
177
- if (!showInRight && showInLeft) {
178
- left = selectionRect.right - pickerWidth + scrollLeft
179
- }
180
- if (!showInRight) {
181
- placement = placement.replace('left', 'right') //右边放不下去
182
- // left = selectionRect.right - pickerWidth + scrollLeft
183
- }
184
- } else {
185
- top = selectionRect.height + offset;
186
- left = 0;
187
- }
188
- } else if ((hasBottom && !showInBottom) || (hasTop && showInTop)) {
189
- if (transfer) {
190
- left = showInRight ? selectionRect.left + scrollLeft : selectionRect.right - pickerWidth + scrollLeft
191
- top = selectionRect.top - pickerHeight - offset + scrollTop
192
- if (placement == 'top' || placement == 'bottom') {
193
- left = selectionRect.left - (pickerWidth - selectionRect.width) / 2 + scrollLeft
194
- }
195
- if (placement == 'top-right' || placement == 'bottom-right') {
196
- left = selectionRect.left - (pickerWidth - selectionRect.width) + scrollLeft
197
- }
198
- if (hasBottom) {
199
- placement = placement.replace('bottom', 'top')
200
- }
201
- if (!showInRight) {
202
- placement = placement.replace('left', 'right')
203
- }
204
- } else {
205
- top = -(pickerHeight + offset);
206
- left = 0;
207
- }
208
- }
209
- } else if (hasLeft || hasRight) {
210
- if ((hasLeft && showInLeft) || (hasRight && !showInRight)) {
211
- if (transfer) {
212
- top = selectionRect.top + scrollTop
213
- left = selectionRect.left - pickerWidth - offset + scrollLeft
214
- if (placement == 'left' || placement == 'right') {
215
- top = selectionRect.top - (pickerHeight - selectionRect.height) / 2 + scrollTop
216
- }
217
- if (placement == 'left-bottom' || placement == 'right-bottom') {
218
- top = selectionRect.top - (pickerHeight - selectionRect.height) + scrollTop
219
- }
220
- if (hasRight) {
221
- placement = placement.replace('right', 'left')
222
- }
223
- } else {
224
- top = 0
225
- left = -(pickerWidth + offset)
226
- }
227
- } else if ((hasRight && showInRight) || (hasLeft && !showInLeft)) {
228
- if (transfer) {
229
- top = selectionRect.top + scrollTop
230
- left = selectionRect.left + selectionRect.width + offset + scrollLeft
231
- if (placement == 'right' || placement == 'left') {
232
- top = selectionRect.top + scrollTop - (pickerHeight - selectionRect.height) / 2
233
- }
234
- if (placement == 'right-bottom' || placement == 'left-bottom') {
235
- top = selectionRect.top + scrollTop - (pickerHeight - selectionRect.height)
236
- }
237
- if (hasLeft) {
238
- placement = placement.replace('left', 'right')
239
- }
240
- } else {
241
125
 
242
- }
243
- }
244
- if (transfer && !showInBottom && (hasRight || hasLeft)) {
245
- top = selectionRect.top - (pickerHeight - selectionRect.height) + scrollTop
246
- if (hasRight) {
247
- placement = showInRight ? 'right-bottom' : 'left-bottom'
248
- }
249
- if (hasLeft) {
250
- placement = showInLeft ? 'left-bottom' : 'right-bottom'
251
- }
252
- }
253
- }
254
- // console.log(placement, showInBottom,picker, pickerHeight,pickerWidth)
255
- }
256
- let origin = origins[placement]
257
- if (callback) {
258
- callback(top, left, origin, placement)
259
- }
260
- }
261
126
  export function getOffset(el) {
262
127
  // const rect = el.getBoundingClientRect();
263
128
  const pos = el ? {
@@ -89,10 +89,10 @@
89
89
  }
90
90
  }
91
91
  &-slide-leave-to {
92
- animation: k-alert-slide-out 0.3s ease-in-out;
92
+ animation: k-alert-slide 0.3s ease-in-out;
93
93
  animation-fill-mode: both;
94
94
  }
95
- @keyframes k-alert-slide-out {
95
+ @keyframes k-alert-slide {
96
96
  0% {
97
97
  transform: scaleY(1);
98
98
  transform-origin: 0% 0%;
@@ -1,5 +1,5 @@
1
- import { getChild, cloneVNode } from '../_tool/utils'
2
-
1
+ import { getChild } from '../_tool/utils'
2
+ import cloneVNode from 'components/_tool/clone'
3
3
  export default {
4
4
  props: {
5
5
  maxCount: Number,
@@ -1,59 +1,56 @@
1
1
  @import '../../styles/var.less';
2
+
2
3
  .k-backtop {
3
- box-sizing: border-box;
4
- margin: 0;
5
- padding: 0;
6
- list-style: none;
7
- z-index: 10;
8
- position: fixed;
9
- right: 50px;
10
- bottom: 50px;
11
- height: 40px;
12
- width: 40px;
13
- cursor: pointer;
14
- display: block;
15
- overflow: hidden;
16
- border-radius: var(--kui-border-radius);
17
- &-content {
18
- background-color: rgba(0, 0, 0, .45);
19
- opacity: .5;
20
- height: 40px;
21
- transition: opacity .3s ease-in-out;
22
- text-align: center;
23
- line-height: 40px;
24
- color: #fff;
25
- &:hover {
26
- opacity: 1;
27
- }
28
- .k-ion {
29
- font-size: 20px;
30
- color: #fff;
31
- }
32
- }
33
- }
4
+ box-sizing: border-box;
5
+ margin: 0;
6
+ padding: 0;
7
+ list-style: none;
8
+ z-index: 10;
9
+ position: fixed;
10
+ right: 50px;
11
+ bottom: 50px;
12
+ height: 40px;
13
+ width: 40px;
14
+ cursor: pointer;
15
+ display: block;
16
+ overflow: hidden;
17
+ border-radius: var(--kui-border-radius);
18
+
19
+ &-content {
20
+ background-color: rgba(0, 0, 0, .45);
21
+ opacity: .5;
22
+ height: 40px;
23
+ transition: opacity .3s ease-in-out;
24
+ text-align: center;
25
+ line-height: 40px;
26
+ color: #fff;
34
27
 
35
- @keyframes k-backtop-fade-in {
36
- from {
37
- opacity: 0;
38
- }
39
- to {
40
- opacity: 1;
41
- }
28
+ &:hover {
29
+ opacity: 1;
30
+ }
31
+
32
+ .k-ion {
33
+ font-size: 20px;
34
+ color: #fff;
35
+ }
36
+ }
42
37
  }
43
38
 
44
- @keyframes k-backtop-fade-out {
45
- from {
46
- opacity: 1;
47
- }
48
- to {
49
- opacity: 0;
50
- }
39
+ @keyframes k-backtop-fade {
40
+ from {
41
+ opacity: 0;
42
+ }
43
+
44
+ to {
45
+ opacity: 1;
46
+ }
51
47
  }
52
48
 
49
+
53
50
  .k-backtop-fade-enter-active {
54
- animation: k-backtop-fade-in .4s;
51
+ animation: k-backtop-fade .4s;
55
52
  }
56
53
 
57
54
  .k-backtop-fade-leave-active {
58
- animation: k-backtop-fade-out .4s;
55
+ animation: k-backtop-fade .4s reverse;
59
56
  }
@@ -16,14 +16,18 @@ export default {
16
16
  trigger: { type: String, default: "click" },
17
17
  transitionName: { type: String, default: 'dropdown' },
18
18
  selection: { validator: v => true },
19
- updateKey: [String, Object, Array]
19
+ updateKey: [String, Object, Array],
20
+ offsetLeft: { type: Number, default: 0 },
21
+ extendWidth: Boolean
20
22
  },
21
23
 
22
24
  watch: {
23
- updateKey() {
24
- this.$nextTick(e => {
25
- this.setPosition()
26
- })
25
+ updateKey(o, v) {
26
+ if (o != v) {
27
+ this.$nextTick(e => {
28
+ this.setPosition()
29
+ })
30
+ }
27
31
  },
28
32
  rendered(value) {
29
33
  this.$emit('render')
@@ -31,9 +35,14 @@ export default {
31
35
  value(value) {
32
36
  this.rendered = true
33
37
  this.visible = value
34
- this.$nextTick(e => {
35
- this.setPosition()
36
- })
38
+
39
+ if (value) {
40
+ this.left = 0
41
+ this.top = 0
42
+ this.$nextTick(e => {
43
+ this.setPosition()
44
+ })
45
+ }
37
46
  },
38
47
  placement(value) {
39
48
  this.currentPlacement = value
@@ -114,18 +123,223 @@ export default {
114
123
  onMouseDown({ target }) {
115
124
  this.mousedownIn = this.visible && this.$el.contains(target)
116
125
  },
117
- setPosition(e) {
126
+ setPosition() {
118
127
  if (this.trigger == 'contextmenu' || !this.rendered || !this.value) {
119
128
  return;
120
129
  }
121
- let { selection, transfer, placement } = this
122
- getPosition(selection, this.$el, transfer, placement, (top, left, origin, placement) => {
123
- this.top = top
124
- this.left = left
125
- // this.minWidth = this.selection.offsetWidth
126
- this.transformOrigin = origin
127
- this.currentPlacement = placement
128
- })
130
+ let { selection, placement = 'bottom', offsetLeft } = this
131
+ let picker = this.$el
132
+ if (this.extendWidth) {
133
+ picker.style.width = selection.offsetWidth + 'px'
134
+ }
135
+ let top = 0, left = 0, offset = 3;
136
+
137
+ let origin = ["", ""]
138
+
139
+ if (picker && selection) {
140
+
141
+ let selectionRect = selection.getBoundingClientRect();
142
+ let pickerHeight = picker.offsetHeight
143
+ let pickerWidth = picker.offsetWidth
144
+ let clientHeight = document.documentElement.clientHeight
145
+ let clientWidth = document.documentElement.clientWidth
146
+ let scrollTop = document.documentElement.scrollTop
147
+ let scrollLeft = document.documentElement.scrollLeft
148
+
149
+ //是否有足够的空间
150
+ //底部
151
+ let enoughBottom = clientHeight - selectionRect.bottom > pickerHeight
152
+ let enoughBottomC = clientHeight - selectionRect.top > pickerHeight
153
+ //上面
154
+ let enoughTop = selectionRect.top > pickerHeight
155
+ let enoughTopC = selectionRect.bottom > pickerHeight
156
+ //左边
157
+ let enoughLeft = selectionRect.left > pickerWidth
158
+ let enoughLeftC = selectionRect.right > pickerWidth
159
+ //右边
160
+ let enoughRight = clientWidth - selectionRect.right > pickerWidth
161
+ let enoughRightC = clientWidth - selectionRect.left > pickerWidth
162
+
163
+ // console.log(showInRight, selectionRect.left > pickerWidth, selectionRect.right, pickerWidth)
164
+ // console.log(selectionRect.right, pickerWidth, placement, ', bottom:', enoughBottom, 'top:', enoughTop, 'left:', enoughLeft, 'leftC:', enoughLeftC, 'right:', enoughRight, 'rightC:', enoughRightC)
165
+ // console.log(placement, 'showInTop:', showInTop, 'showInBottom:', showInBottom, clientHeight, scrollTop, selectionRect.top, pickerHeight)
166
+
167
+ //reset placement
168
+ if (placement.startsWith('top')) {
169
+ if (!enoughTop) {
170
+ placement = placement.replace('top', 'bottom')
171
+ }
172
+ if (!enoughLeftC) {
173
+ placement = placement.replace('right', 'left')
174
+
175
+ if (placement == 'top') {
176
+ placement = "top-left"
177
+ }
178
+ if (placement == 'bottom') {
179
+ placement = "bottom-left"
180
+ }
181
+ }
182
+ if (!enoughRightC) {
183
+ placement = placement.replace('left', 'right')
184
+
185
+ if (placement == 'bottom') {
186
+ placement = "bottom-right"
187
+ }
188
+
189
+ if (placement == 'top') {
190
+ placement = "top-right"
191
+ }
192
+ }
193
+
194
+
195
+ } else if (placement.startsWith('right')) {
196
+ if (!enoughRight) {
197
+ placement = placement.replace('right', 'left')
198
+ }
199
+ if (!enoughBottomC) {
200
+ placement = placement.replace('top', 'bottom')
201
+ if (placement == 'right') {
202
+ placement = 'right-bottom'
203
+ }
204
+ if (placement == 'left') {
205
+ placement = 'left-bottom'
206
+ }
207
+ }
208
+ if (!enoughTopC) {
209
+ placement = placement.replace('bottom', 'top')// ok
210
+ if (placement == 'left') {
211
+ placement = 'left-top'
212
+ }
213
+ if (placement == 'right') {
214
+ placement = 'right-top'
215
+ }
216
+ }
217
+
218
+ } else if (placement.startsWith('bottom')) {
219
+ if (!enoughBottom) {
220
+ placement = placement.replace('bottom', 'top')
221
+ }
222
+
223
+ if (!enoughLeftC) {
224
+ placement = placement.replace('right', 'left')
225
+
226
+ if (placement == 'bottom') {
227
+ placement = "bottom-left"
228
+ }
229
+
230
+ if (placement == 'top') {
231
+ placement = "top-left"
232
+ }
233
+ }
234
+ if (!enoughRightC) {
235
+ placement = placement.replace('left', 'right')
236
+
237
+ if (placement == 'top') {
238
+ placement = "top-right"
239
+ }
240
+ if (placement == 'bottom') {
241
+ placement = "bottom-right"
242
+ }
243
+ }
244
+
245
+ } else if (placement.startsWith('left')) {
246
+ if (!enoughLeft) {
247
+ placement = placement.replace('left', 'right')
248
+ }
249
+ if (!enoughTopC) {
250
+ placement = placement.replace('bottom', 'top')
251
+ if (placement == 'right') {
252
+ placement = 'right-top'
253
+ }
254
+ if (placement == 'left') {
255
+ placement = 'left-top'
256
+ }
257
+ }
258
+ if (!enoughBottomC) {
259
+ placement = placement.replace('top', 'bottom')
260
+ if (placement == 'right') {
261
+ placement = 'right-bottom'
262
+ }
263
+ if (placement == 'left') {
264
+ placement = 'left-bottom'
265
+ }
266
+ }
267
+
268
+ }
269
+
270
+
271
+ // console.log('result:' + placement)
272
+
273
+ // set postion
274
+ if (!placement.includes('-')) {
275
+ //equal
276
+ if (placement == 'top') {
277
+ top = selectionRect.top - pickerHeight - offset + scrollTop
278
+ left = selectionRect.left + (selectionRect.width - pickerWidth) / 2 + scrollLeft
279
+ origin = ['center', 'bottom']
280
+ }
281
+ if (placement == 'bottom') {
282
+ top = selectionRect.bottom + offset + scrollTop
283
+ left = selectionRect.left + (selectionRect.width - pickerWidth) / 2 + scrollLeft
284
+ origin = ['center', 'top']
285
+ }
286
+ if (placement == 'left') {
287
+ left = selectionRect.left - pickerWidth - offset + scrollLeft
288
+ top = selectionRect.top + (selectionRect.height - pickerHeight) / 2 + scrollTop
289
+ origin = ['right', 'center']
290
+ }
291
+ if (placement == 'right') {
292
+ left = selectionRect.right + offset + scrollLeft
293
+ top = selectionRect.top + (selectionRect.height - pickerHeight) / 2 + scrollTop
294
+ origin = ['left', 'center']
295
+ }
296
+ } else {
297
+ //start
298
+ if (placement.startsWith('bottom')) {
299
+ top = selectionRect.bottom + offset + scrollTop
300
+ origin[1] = 'top'
301
+ }
302
+ if (placement.startsWith('right')) {
303
+ left = selectionRect.right + offset + scrollLeft
304
+ origin[0] = 'left'
305
+ }
306
+ if (placement.startsWith('top')) {
307
+ top = selectionRect.top - pickerHeight - offset + scrollTop
308
+ origin[1] = 'bottom'
309
+ }
310
+ if (placement.startsWith('left')) {
311
+ left = selectionRect.left - pickerWidth - offset + scrollLeft
312
+ origin[0] = 'right'
313
+ }
314
+ //end
315
+
316
+ if (placement.endsWith('left')) {
317
+ left = selectionRect.left + scrollLeft
318
+ origin[0] = 'left'
319
+ }
320
+ if (placement.endsWith('right')) {
321
+ left = selectionRect.right - pickerWidth + scrollLeft - 0.5
322
+ origin[0] = 'right'
323
+ }
324
+
325
+ if (placement.endsWith('bottom')) {
326
+ top = selectionRect.bottom - pickerHeight + scrollTop
327
+ origin[1] = 'bottom'
328
+ }
329
+ if (placement.endsWith('top')) {
330
+ top = selectionRect.top + scrollTop
331
+ origin[1] = 'top'
332
+ }
333
+
334
+ }
335
+ }
336
+ // console.log(placement, origin)
337
+ this.top = top
338
+ this.left = left + (placement.includes('right') ? offsetLeft : -offsetLeft)
339
+
340
+ this.transformOrigin = origin.join(' ')
341
+ this.currentPlacement = placement
342
+
129
343
  },
130
344
  hide(e) {
131
345
  let { target } = e