@@ -122,7 +122,11 @@ export default {
122
122
// update wrapper tooltip
123
123
const tooltipEl = this .$data ._bodyEl .children [0 ]
124
124
tooltipEl .classList .forEach ((item ) => tooltipEl .classList .remove (item))
125
- if (this .$vnode && this .$vnode .data && this .$vnode .data .staticClass ) {
125
+ if (
126
+ this .$vnode &&
127
+ this .$vnode .data &&
128
+ this .$vnode .data .staticClass
129
+ ) {
126
130
tooltipEl .classList .add (this .$vnode .data .staticClass )
127
131
}
128
132
this .rootClasses .forEach ((item ) => {
@@ -136,17 +140,45 @@ export default {
136
140
tooltipEl .classList .add (item)
137
141
}
138
142
})
139
- tooltipEl .style .width = ` ${ trigger .clientWidth } px`
140
- tooltipEl .style .height = ` ${ trigger .clientHeight } px`
143
+
141
144
const rect = trigger .getBoundingClientRect ()
145
+
142
146
let top = rect .top + window .scrollY
143
147
let left = rect .left + window .scrollX
148
+
149
+ const quaterHeight = trigger .clientHeight / 2 / 2
150
+
151
+ switch (this .position ) {
152
+ case ' is-top' :
153
+ tooltipEl .style .width = ` ${ trigger .clientWidth } px`
154
+ tooltipEl .style .height = ` 0px`
155
+ top -= trigger .clientHeight - quaterHeight
156
+ break
157
+ case ' is-bottom' :
158
+ tooltipEl .style .width = ` ${ trigger .clientWidth } px`
159
+ tooltipEl .style .height = ` 0px`
160
+ top += quaterHeight
161
+ break
162
+ case ' is-left' :
163
+ tooltipEl .style .width = ` 0px`
164
+ tooltipEl .style .height = ` ${ trigger .clientHeight } px`
165
+ break
166
+ case ' is-right' :
167
+ tooltipEl .style .width = ` 0px`
168
+ tooltipEl .style .height = ` ${ trigger .clientHeight } px`
169
+ left += trigger .clientWidth
170
+ break
171
+ }
172
+
144
173
const wrapper = this .$data ._bodyEl
145
174
wrapper .style .position = ' absolute'
146
175
wrapper .style .top = ` ${ top} px`
147
176
wrapper .style .left = ` ${ left} px`
177
+ wrapper .style .width = ` 0px`
148
178
wrapper .style .zIndex = this .isActive || this .always ? ' 99' : ' -1'
149
- this .triggerStyle = { zIndex: this .isActive || this .always ? ' 100' : undefined }
179
+ this .triggerStyle = {
180
+ zIndex: this .isActive || this .always ? ' 100' : undefined
181
+ }
150
182
}
151
183
},
152
184
onClick () {
0 commit comments