uview-plus 3.4.105 → 3.4.106
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
CHANGED
|
@@ -32,7 +32,7 @@ export const props = defineMixin({
|
|
|
32
32
|
type: String,
|
|
33
33
|
default: () => defProps.tooltip.popupBgColor
|
|
34
34
|
},
|
|
35
|
-
// 弹出提示的方向,top-上方,bottom
|
|
35
|
+
// 弹出提示的方向,top-上方,bottom-下方,left-左方,right-右方
|
|
36
36
|
direction: {
|
|
37
37
|
type: String,
|
|
38
38
|
default: () => defProps.tooltip.direction
|
|
@@ -68,4 +68,4 @@ export const props = defineMixin({
|
|
|
68
68
|
default: () => defProps.tooltip.triggerMode
|
|
69
69
|
},
|
|
70
70
|
}
|
|
71
|
-
})
|
|
71
|
+
})
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
@click="overlayClickHandler"
|
|
10
10
|
></u-overlay>
|
|
11
11
|
<view class="u-tooltip__wrapper">
|
|
12
|
-
<view class="u-tooltip__trigger"
|
|
12
|
+
<view class="u-tooltip__trigger" :id="textId"
|
|
13
|
+
:ref="textId" @click.stop="clickHander"
|
|
13
14
|
@longpress.stop="longpressHandler">
|
|
14
15
|
<slot name="trigger"></slot>
|
|
15
16
|
<text v-if="!$slots['trigger']"
|
|
16
17
|
class="u-tooltip__wrapper__text"
|
|
17
|
-
:id="textId"
|
|
18
|
-
:ref="textId"
|
|
19
18
|
:userSelect="false"
|
|
20
19
|
:selectable="false"
|
|
21
20
|
:style="{
|
|
@@ -156,11 +155,13 @@
|
|
|
156
155
|
screenGap: 12,
|
|
157
156
|
// 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
|
|
158
157
|
indicatorWidth: 14,
|
|
158
|
+
tooltipStyle: {}
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
watch: {
|
|
162
|
-
propsChange() {
|
|
163
|
-
this.getElRect()
|
|
162
|
+
async propsChange() {
|
|
163
|
+
await this.getElRect()
|
|
164
|
+
this.getTooltipStyle();
|
|
164
165
|
}
|
|
165
166
|
},
|
|
166
167
|
computed: {
|
|
@@ -169,37 +170,7 @@
|
|
|
169
170
|
propsChange() {
|
|
170
171
|
return [this.text, this.buttons]
|
|
171
172
|
},
|
|
172
|
-
|
|
173
|
-
tooltipStyle() {
|
|
174
|
-
const style = {
|
|
175
|
-
transform: `translateY(${this.direction === 'top' ? '-100%' : '100%'})`,
|
|
176
|
-
},
|
|
177
|
-
sysInfo = getWindowInfo()
|
|
178
|
-
if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) {
|
|
179
|
-
this.indicatorStyle = {}
|
|
180
|
-
style.left = `-${addUnit(this.textInfo.left - this.screenGap)}`
|
|
181
|
-
this.indicatorStyle.left = addUnit(this.textInfo.width / 2 - getPx(style.left) - this.indicatorWidth /
|
|
182
|
-
2)
|
|
183
|
-
} else if (this.tooltipInfo.width / 2 > sysInfo.windowWidth - this.textInfo.right + this.textInfo.width / 2 -
|
|
184
|
-
this.screenGap) {
|
|
185
|
-
this.indicatorStyle = {}
|
|
186
|
-
style.right = `-${addUnit(sysInfo.windowWidth - this.textInfo.right - this.screenGap)}`
|
|
187
|
-
this.indicatorStyle.right = addUnit(this.textInfo.width / 2 - getPx(style.right) - this
|
|
188
|
-
.indicatorWidth / 2)
|
|
189
|
-
} else {
|
|
190
|
-
const left = Math.abs(this.textInfo.width / 2 - this.tooltipInfo.width / 2)
|
|
191
|
-
style.left = this.textInfo.width > this.tooltipInfo.width ? addUnit(left) : -addUnit(left)
|
|
192
|
-
this.indicatorStyle = {}
|
|
193
|
-
}
|
|
194
|
-
if (this.direction === 'top') {
|
|
195
|
-
style.marginTop = '-10px'
|
|
196
|
-
this.indicatorStyle.bottom = '-4px'
|
|
197
|
-
} else {
|
|
198
|
-
style.marginBottom = '-10px'
|
|
199
|
-
this.indicatorStyle.top = '-4px'
|
|
200
|
-
}
|
|
201
|
-
return style
|
|
202
|
-
}
|
|
173
|
+
|
|
203
174
|
},
|
|
204
175
|
mounted() {
|
|
205
176
|
this.init()
|
|
@@ -208,11 +179,64 @@
|
|
|
208
179
|
methods: {
|
|
209
180
|
addStyle,
|
|
210
181
|
addUnit,
|
|
211
|
-
init() {
|
|
212
|
-
this.getElRect()
|
|
182
|
+
async init() {
|
|
183
|
+
await this.getElRect()
|
|
184
|
+
this.getTooltipStyle();
|
|
185
|
+
},
|
|
186
|
+
// 计算气泡和指示器的位置信息
|
|
187
|
+
getTooltipStyle() {
|
|
188
|
+
const style = {},
|
|
189
|
+
sysInfo = getWindowInfo()
|
|
190
|
+
if (this.direction === 'left') {
|
|
191
|
+
// 右侧显示逻辑
|
|
192
|
+
style.transform = ``
|
|
193
|
+
// 垂直居中对齐
|
|
194
|
+
style.top = '-' + addUnit((this.tooltipInfo.height - this.indicatorWidth) / 2, 'px')
|
|
195
|
+
style.right = addUnit(this.textInfo.width + this.indicatorWidth, 'px')
|
|
196
|
+
this.indicatorStyle = {}
|
|
197
|
+
this.indicatorStyle.right = '-4px'
|
|
198
|
+
this.indicatorStyle.top = addUnit((this.tooltipInfo.height - this.indicatorWidth) / 2, 'px')
|
|
199
|
+
} else if (this.direction === 'right') {
|
|
200
|
+
// 右侧显示逻辑
|
|
201
|
+
style.transform = ``
|
|
202
|
+
// 垂直居中对齐
|
|
203
|
+
style.top = addUnit((this.textInfo.height - this.tooltipInfo.height) / 2, 'px')
|
|
204
|
+
style.left = addUnit(this.textInfo.width + this.indicatorWidth, 'px')
|
|
205
|
+
this.indicatorStyle = {}
|
|
206
|
+
this.indicatorStyle.left = '-4px'
|
|
207
|
+
this.indicatorStyle.top = addUnit((this.textInfo.height - this.indicatorWidth) / 2, 'px')
|
|
208
|
+
} else if (this.direction === 'top' || this.direction === 'bottom') {
|
|
209
|
+
style.transform = `translateY(${this.direction === 'top' ? '-100%' : '100%'})`
|
|
210
|
+
if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) {
|
|
211
|
+
this.indicatorStyle = {}
|
|
212
|
+
style.left = `-${addUnit(this.textInfo.left - this.screenGap)}`
|
|
213
|
+
this.indicatorStyle.left = addUnit(this.textInfo.width / 2 - getPx(style.left) - this.indicatorWidth /
|
|
214
|
+
2, 'px')
|
|
215
|
+
} else if (this.tooltipInfo.width / 2 > sysInfo.windowWidth - this.textInfo.right + this.textInfo.width / 2 -
|
|
216
|
+
this.screenGap) {
|
|
217
|
+
this.indicatorStyle = {}
|
|
218
|
+
style.right = `-${addUnit(sysInfo.windowWidth - this.textInfo.right - this.screenGap)}`
|
|
219
|
+
this.indicatorStyle.right = addUnit(this.textInfo.width / 2 - getPx(style.right) - this
|
|
220
|
+
.indicatorWidth / 2)
|
|
221
|
+
} else {
|
|
222
|
+
const left = Math.abs(this.textInfo.width / 2 - this.tooltipInfo.width / 2)
|
|
223
|
+
style.left = this.textInfo.width > this.tooltipInfo.width ? addUnit(left) : -addUnit(left)
|
|
224
|
+
this.indicatorStyle = {}
|
|
225
|
+
}
|
|
226
|
+
if (this.direction === 'top') {
|
|
227
|
+
style.marginTop = '-10px'
|
|
228
|
+
this.indicatorStyle.bottom = '-4px'
|
|
229
|
+
} else {
|
|
230
|
+
style.marginBottom = '-10px'
|
|
231
|
+
this.indicatorStyle.top = '-4px'
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this.tooltipStyle = style
|
|
235
|
+
return style
|
|
213
236
|
},
|
|
214
237
|
// 点击触发事件
|
|
215
|
-
clickHander() {
|
|
238
|
+
async clickHander() {
|
|
239
|
+
// this.getTooltipStyle();
|
|
216
240
|
if (this.triggerMode == 'click') {
|
|
217
241
|
this.tooltipTop = 0
|
|
218
242
|
this.showTooltip = true
|
|
@@ -220,6 +244,7 @@
|
|
|
220
244
|
},
|
|
221
245
|
// 长按触发事件
|
|
222
246
|
async longpressHandler() {
|
|
247
|
+
// this.getTooltipStyle();
|
|
223
248
|
if (this.triggerMode == 'longpress') {
|
|
224
249
|
this.tooltipTop = 0
|
|
225
250
|
this.showTooltip = true
|
|
@@ -238,7 +263,7 @@
|
|
|
238
263
|
// 查询内容高度
|
|
239
264
|
queryRect(ref) {
|
|
240
265
|
// #ifndef APP-NVUE
|
|
241
|
-
// $uGetRect为
|
|
266
|
+
// $uGetRect为uview-plus自带的节点查询简化方法,详见文档介绍:https://ijry.github.io/uview-plus/js/getRect.html
|
|
242
267
|
// 组件内部一般用this.$uGetRect,对外的为uni.$u.getRect,二者功能一致,名称不同
|
|
243
268
|
return new Promise(resolve => {
|
|
244
269
|
this.$uGetRect(`#${ref}`).then(size => {
|
|
@@ -259,17 +284,16 @@
|
|
|
259
284
|
},
|
|
260
285
|
// 元素尺寸
|
|
261
286
|
getElRect() {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
this.tooltipInfo =
|
|
287
|
+
return new Promise(async(resolve) => {
|
|
288
|
+
// 调用之前,先将指示器调整到屏幕外,方便获取尺寸
|
|
289
|
+
this.showTooltip = true
|
|
290
|
+
this.tooltipTop = -10000
|
|
291
|
+
sleep(500).then(async () => {
|
|
292
|
+
this.tooltipInfo = await this.queryRect(this.tooltipId)
|
|
268
293
|
// 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
|
|
269
294
|
this.showTooltip = false
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.textInfo = size
|
|
295
|
+
this.textInfo = await this.queryRect(this.textId)
|
|
296
|
+
resolve()
|
|
273
297
|
})
|
|
274
298
|
})
|
|
275
299
|
},
|
|
@@ -360,4 +384,4 @@
|
|
|
360
384
|
}
|
|
361
385
|
}
|
|
362
386
|
}
|
|
363
|
-
</style>
|
|
387
|
+
</style>
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"id": "uview-plus",
|
|
3
3
|
"name": "uview-plus",
|
|
4
4
|
"displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙跨端移动组件库,组件丰富维护更新稳定。",
|
|
5
|
-
"version": "3.4.
|
|
6
|
-
"description": "零云®uview-plus已兼容vue3,100
|
|
5
|
+
"version": "3.4.106",
|
|
6
|
+
"description": "零云®uview-plus已兼容vue3,100+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uview",
|
|
9
9
|
"uview-plus",
|