@tarojs/taro-h5 3.5.0-alpha.13 → 3.5.0-alpha.16
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/api/ad/index.d.ts +6 -0
- package/dist/api/ai/facial.d.ts +9 -0
- package/dist/api/ai/index.d.ts +2 -0
- package/dist/api/ai/visual.d.ts +6 -0
- package/dist/api/alipay/index.d.ts +3 -0
- package/dist/api/base/crypto.d.ts +3 -0
- package/dist/api/base/debug.d.ts +9 -0
- package/dist/api/base/index.d.ts +12 -0
- package/dist/api/base/performance.d.ts +6 -0
- package/dist/api/base/system.d.ts +27 -0
- package/dist/api/base/system.js +2 -2
- package/dist/api/base/update.d.ts +6 -0
- package/dist/api/base/weapp/app-event.d.ts +41 -0
- package/dist/api/base/weapp/app-event.js +55 -4
- package/dist/api/base/weapp/life-cycle.d.ts +6 -0
- package/dist/api/canvas/CanvasContext.d.ts +104 -0
- package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
- package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.js +1 -1
- package/dist/api/canvas/createCanvasContext.d.ts +5 -0
- package/dist/api/canvas/index.d.ts +12 -0
- package/dist/api/cloud/index.d.ts +31 -0
- package/dist/api/data-analysis/index.d.ts +12 -0
- package/dist/api/device/accelerometer.d.ts +17 -0
- package/dist/api/device/accessibility.d.ts +3 -0
- package/dist/api/device/battery.d.ts +5 -0
- package/dist/api/device/bluetooth-ble.d.ts +48 -0
- package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
- package/dist/api/device/bluetooth.d.ts +39 -0
- package/dist/api/device/calendar.d.ts +6 -0
- package/dist/api/device/clipboard.d.ts +15 -0
- package/dist/api/device/compass.d.ts +17 -0
- package/dist/api/device/contact.d.ts +6 -0
- package/dist/api/device/crypto.d.ts +3 -0
- package/dist/api/device/gyroscope.d.ts +12 -0
- package/dist/api/device/iBeacon.d.ts +21 -0
- package/dist/api/device/index.d.ts +23 -0
- package/dist/api/device/keyboard.d.ts +12 -0
- package/dist/api/device/memory.d.ts +6 -0
- package/dist/api/device/motion.d.ts +17 -0
- package/dist/api/device/network.d.ts +20 -0
- package/dist/api/device/nfc.d.ts +21 -0
- package/dist/api/device/phone.d.ts +2 -0
- package/dist/api/device/scan.d.ts +3 -0
- package/dist/api/device/screen.d.ts +18 -0
- package/dist/api/device/vibrate.d.ts +9 -0
- package/dist/api/device/vibrate.js +5 -7
- package/dist/api/device/wifi.d.ts +33 -0
- package/dist/api/ext/index.d.ts +6 -0
- package/dist/api/files/index.d.ts +24 -0
- package/dist/api/framework/index.d.ts +4 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/location/chooseLocation.d.ts +6 -0
- package/dist/api/location/getLocation.d.ts +2 -0
- package/dist/api/location/index.d.ts +32 -0
- package/dist/api/location/index.js +1 -0
- package/dist/api/media/EditorContext.d.ts +42 -0
- package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/api/media/audio/index.d.ts +29 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
- package/dist/api/media/background-audio/index.d.ts +29 -0
- package/dist/api/media/camera.d.ts +3 -0
- package/dist/api/media/image/chooseImage.d.ts +5 -0
- package/dist/api/media/image/getImageInfo.d.ts +5 -0
- package/dist/api/media/image/index.d.ts +15 -0
- package/dist/api/media/image/previewImage.d.ts +8 -0
- package/dist/api/media/index.d.ts +12 -0
- package/dist/api/media/live.d.ts +6 -0
- package/dist/api/media/map.d.ts +3 -0
- package/dist/api/media/media-recorder.d.ts +3 -0
- package/dist/api/media/recorder.d.ts +9 -0
- package/dist/api/media/video/index.d.ts +24 -0
- package/dist/api/media/video-decoder.d.ts +3 -0
- package/dist/api/media/video-processing.d.ts +3 -0
- package/dist/api/media/voip.d.ts +42 -0
- package/dist/api/navigate/index.d.ts +12 -0
- package/dist/api/network/download.d.ts +6 -0
- package/dist/api/network/download.js +1 -0
- package/dist/api/network/index.d.ts +7 -0
- package/dist/api/network/mdns.d.ts +30 -0
- package/dist/api/network/request/index.d.ts +4 -0
- package/dist/api/network/tcp.d.ts +3 -0
- package/dist/api/network/udp.d.ts +3 -0
- package/dist/api/network/upload.d.ts +5 -0
- package/dist/api/network/upload.js +2 -1
- package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
- package/dist/api/network/utils.js +1 -0
- package/dist/api/network/websocket/index.d.ts +7 -0
- package/dist/api/network/websocket/socketTask.d.ts +25 -0
- package/dist/api/open-api/account.d.ts +3 -0
- package/dist/api/open-api/address.d.ts +3 -0
- package/dist/api/open-api/authorize.d.ts +6 -0
- package/dist/api/open-api/card.d.ts +6 -0
- package/dist/api/open-api/channels-live.d.ts +18 -0
- package/dist/api/open-api/customer-service.d.ts +3 -0
- package/dist/api/open-api/facial.d.ts +12 -0
- package/dist/api/open-api/favorites.d.ts +6 -0
- package/dist/api/open-api/group.d.ts +3 -0
- package/dist/api/open-api/index.d.ts +18 -0
- package/dist/api/open-api/invoice.d.ts +6 -0
- package/dist/api/open-api/license-plate.d.ts +3 -0
- package/dist/api/open-api/login.d.ts +9 -0
- package/dist/api/open-api/red-package.d.ts +3 -0
- package/dist/api/open-api/settings.d.ts +6 -0
- package/dist/api/open-api/soter.d.ts +9 -0
- package/dist/api/open-api/subscribe-message.d.ts +3 -0
- package/dist/api/open-api/user-info.d.ts +6 -0
- package/dist/api/open-api/werun.d.ts +6 -0
- package/dist/api/payment/index.d.ts +6 -0
- package/dist/api/route/index.d.ts +1 -0
- package/dist/api/share/index.d.ts +30 -0
- package/dist/api/storage/background-fetch.d.ts +12 -0
- package/dist/api/storage/index.d.ts +18 -0
- package/dist/api/swan/index.d.ts +63 -0
- package/dist/api/taro.d.ts +12 -0
- package/dist/api/ui/animation/index.d.ts +2 -0
- package/dist/api/ui/background.d.ts +6 -0
- package/dist/api/ui/custom-component.d.ts +1 -0
- package/dist/api/ui/fonts.d.ts +2 -0
- package/dist/api/ui/index.d.ts +12 -0
- package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
- package/dist/api/ui/interaction/index.d.ts +14 -0
- package/dist/api/ui/interaction/modal.d.ts +69 -0
- package/dist/api/ui/interaction/modal.js +1 -0
- package/dist/api/ui/interaction/toast.d.ts +85 -0
- package/dist/api/ui/menu.d.ts +3 -0
- package/dist/api/ui/navigation-bar/index.d.ts +15 -0
- package/dist/api/ui/navigation-bar/index.js +2 -3
- package/dist/api/ui/pull-down-refresh.d.ts +9 -0
- package/dist/api/ui/scroll/index.d.ts +5 -0
- package/dist/api/ui/sticky.d.ts +3 -0
- package/dist/api/ui/tab-bar.d.ts +34 -0
- package/dist/api/ui/window.d.ts +15 -0
- package/dist/api/worker/index.d.ts +3 -0
- package/dist/api/wxml/index.d.ts +5 -0
- package/dist/api/wxml/nodesRef.d.ts +13 -0
- package/dist/api/wxml/selectorQuery.d.ts +24 -0
- package/dist/api/wxml/selectorQuery.js +1 -1
- package/dist/index.cjs.d.ts +1373 -0
- package/dist/index.cjs.js +105 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.d.ts +1373 -0
- package/dist/index.esm.js +93 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +1364 -0
- package/dist/taroApis.js +1 -1
- package/dist/utils/animation.d.ts +6 -0
- package/dist/utils/handler.d.ts +48 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +3 -7
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/valid.d.ts +2 -0
- package/package.json +17 -19
- package/types/api.d.ts +4 -0
- package/types/define.d.ts +2 -0
- package/types/index.d.ts +33 -0
- package/types/overlay.d.ts +9 -0
- package/LICENSE +0 -21
- package/src/api/ad/index.ts +0 -5
- package/src/api/ai/facial.ts +0 -6
- package/src/api/ai/index.ts +0 -2
- package/src/api/ai/visual.ts +0 -7
- package/src/api/alipay/index.ts +0 -4
- package/src/api/base/crypto.ts +0 -4
- package/src/api/base/debug.ts +0 -5
- package/src/api/base/index.ts +0 -23
- package/src/api/base/performance.ts +0 -5
- package/src/api/base/system.ts +0 -207
- package/src/api/base/update.ts +0 -5
- package/src/api/base/weapp/app-event.ts +0 -19
- package/src/api/base/weapp/life-cycle.ts +0 -5
- package/src/api/canvas/CanvasContext.ts +0 -233
- package/src/api/canvas/canvasGetImageData.ts +0 -28
- package/src/api/canvas/canvasPutImageData.ts +0 -25
- package/src/api/canvas/canvasToTempFilePath.ts +0 -25
- package/src/api/canvas/createCanvasContext.ts +0 -19
- package/src/api/canvas/index.ts +0 -18
- package/src/api/cloud/index.ts +0 -32
- package/src/api/data-analysis/index.ts +0 -6
- package/src/api/device/accelerometer.ts +0 -79
- package/src/api/device/accessibility.ts +0 -4
- package/src/api/device/battery.ts +0 -23
- package/src/api/device/bluetooth-ble.ts +0 -19
- package/src/api/device/bluetooth-peripheral.ts +0 -6
- package/src/api/device/bluetooth.ts +0 -16
- package/src/api/device/calendar.ts +0 -5
- package/src/api/device/clipboard.ts +0 -68
- package/src/api/device/compass.ts +0 -83
- package/src/api/device/contact.ts +0 -5
- package/src/api/device/crypto.ts +0 -4
- package/src/api/device/gyroscope.ts +0 -7
- package/src/api/device/iBeacon.ts +0 -10
- package/src/api/device/index.ts +0 -23
- package/src/api/device/keyboard.ts +0 -7
- package/src/api/device/memory.ts +0 -5
- package/src/api/device/motion.ts +0 -77
- package/src/api/device/network.ts +0 -90
- package/src/api/device/nfc.ts +0 -10
- package/src/api/device/phone.ts +0 -31
- package/src/api/device/scan.ts +0 -11
- package/src/api/device/screen.ts +0 -9
- package/src/api/device/vibrate.ts +0 -37
- package/src/api/device/wifi.ts +0 -14
- package/src/api/ext/index.ts +0 -5
- package/src/api/files/index.ts +0 -11
- package/src/api/framework/index.ts +0 -10
- package/src/api/index.ts +0 -24
- package/src/api/location/chooseLocation.ts +0 -117
- package/src/api/location/getLocation.ts +0 -81
- package/src/api/location/index.ts +0 -22
- package/src/api/location/style.css +0 -79
- package/src/api/media/EditorContext.ts +0 -32
- package/src/api/media/audio/InnerAudioContext.ts +0 -99
- package/src/api/media/audio/index.ts +0 -21
- package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
- package/src/api/media/background-audio/index.ts +0 -17
- package/src/api/media/camera.ts +0 -4
- package/src/api/media/image/chooseImage.ts +0 -95
- package/src/api/media/image/getImageInfo.ts +0 -50
- package/src/api/media/image/index.ts +0 -13
- package/src/api/media/image/previewImage.ts +0 -80
- package/src/api/media/index.ts +0 -12
- package/src/api/media/live.ts +0 -5
- package/src/api/media/map.ts +0 -4
- package/src/api/media/media-recorder.ts +0 -4
- package/src/api/media/recorder.ts +0 -6
- package/src/api/media/video/index.ts +0 -82
- package/src/api/media/video-decoder.ts +0 -4
- package/src/api/media/video-processing.ts +0 -4
- package/src/api/media/voip.ts +0 -17
- package/src/api/navigate/index.ts +0 -7
- package/src/api/network/download.ts +0 -141
- package/src/api/network/index.ts +0 -7
- package/src/api/network/mdns.ts +0 -13
- package/src/api/network/request/index.ts +0 -135
- package/src/api/network/tcp.ts +0 -4
- package/src/api/network/udp.ts +0 -4
- package/src/api/network/upload.ts +0 -169
- package/src/api/network/websocket/index.ts +0 -88
- package/src/api/network/websocket/socketTask.ts +0 -89
- package/src/api/open-api/account.ts +0 -4
- package/src/api/open-api/address.ts +0 -4
- package/src/api/open-api/authorize.ts +0 -5
- package/src/api/open-api/card.ts +0 -5
- package/src/api/open-api/channels-live.ts +0 -9
- package/src/api/open-api/customer-service.ts +0 -4
- package/src/api/open-api/facial.ts +0 -7
- package/src/api/open-api/favorites.ts +0 -5
- package/src/api/open-api/group.ts +0 -4
- package/src/api/open-api/index.ts +0 -18
- package/src/api/open-api/invoice.ts +0 -5
- package/src/api/open-api/license-plate.ts +0 -4
- package/src/api/open-api/login.ts +0 -6
- package/src/api/open-api/red-package.ts +0 -4
- package/src/api/open-api/settings.ts +0 -5
- package/src/api/open-api/soter.ts +0 -6
- package/src/api/open-api/subscribe-message.ts +0 -4
- package/src/api/open-api/user-info.ts +0 -5
- package/src/api/open-api/werun.ts +0 -5
- package/src/api/payment/index.ts +0 -5
- package/src/api/route/index.ts +0 -10
- package/src/api/share/index.ts +0 -13
- package/src/api/storage/background-fetch.ts +0 -7
- package/src/api/storage/index.ts +0 -182
- package/src/api/swan/index.ts +0 -31
- package/src/api/taro.ts +0 -84
- package/src/api/ui/animation/index.ts +0 -356
- package/src/api/ui/background.ts +0 -5
- package/src/api/ui/custom-component.ts +0 -4
- package/src/api/ui/fonts.ts +0 -64
- package/src/api/ui/index.ts +0 -12
- package/src/api/ui/interaction/actionSheet.ts +0 -212
- package/src/api/ui/interaction/index.ts +0 -302
- package/src/api/ui/interaction/modal.ts +0 -237
- package/src/api/ui/interaction/toast.ts +0 -220
- package/src/api/ui/menu.ts +0 -4
- package/src/api/ui/navigation-bar/index.ts +0 -52
- package/src/api/ui/pull-down-refresh.ts +0 -28
- package/src/api/ui/scroll/index.ts +0 -85
- package/src/api/ui/sticky.ts +0 -4
- package/src/api/ui/tab-bar.ts +0 -327
- package/src/api/ui/window.ts +0 -38
- package/src/api/worker/index.ts +0 -4
- package/src/api/wxml/index.ts +0 -10
- package/src/api/wxml/nodesRef.ts +0 -56
- package/src/api/wxml/selectorQuery.ts +0 -220
- package/src/index.ts +0 -6
- package/src/utils/animation.ts +0 -15
- package/src/utils/handler.ts +0 -105
- package/src/utils/index.ts +0 -184
- package/src/utils/lodash.ts +0 -30
- package/src/utils/valid.ts +0 -8
package/src/api/ui/tab-bar.ts
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import Taro, { AppConfig } from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { getParameterError, isValidColor, shouldBeObject } from '../../utils'
|
|
4
|
-
import { MethodHandler } from '../../utils/handler'
|
|
5
|
-
|
|
6
|
-
let tabConf
|
|
7
|
-
|
|
8
|
-
export function initTabBarApis (config: AppConfig = {}) {
|
|
9
|
-
tabConf = config.tabBar
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 显示 tabBar 某一项的右上角的红点
|
|
14
|
-
*/
|
|
15
|
-
export const showTabBarRedDot: typeof Taro.showTabBarRedDot = (options) => {
|
|
16
|
-
// options must be an Object
|
|
17
|
-
const isObject = shouldBeObject(options)
|
|
18
|
-
if (!isObject.flag) {
|
|
19
|
-
const res = { errMsg: `showTabBarRedDot:fail ${isObject.msg}` }
|
|
20
|
-
console.error(res.errMsg)
|
|
21
|
-
return Promise.reject(res)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
index,
|
|
26
|
-
success,
|
|
27
|
-
fail,
|
|
28
|
-
complete
|
|
29
|
-
} = options
|
|
30
|
-
const handle = new MethodHandler({ name: 'showTabBarRedDot', success, fail, complete })
|
|
31
|
-
|
|
32
|
-
if (typeof index !== 'number') {
|
|
33
|
-
return handle.fail({
|
|
34
|
-
errMsg: getParameterError({
|
|
35
|
-
para: 'index',
|
|
36
|
-
correct: 'Number',
|
|
37
|
-
wrong: index
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
44
|
-
index,
|
|
45
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
46
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 显示 tabBar
|
|
53
|
-
*/
|
|
54
|
-
export const showTabBar: typeof Taro.showTabBar = (options = {}) => {
|
|
55
|
-
// options must be an Object
|
|
56
|
-
const isObject = shouldBeObject(options)
|
|
57
|
-
if (!isObject.flag) {
|
|
58
|
-
const res = { errMsg: `showTabBar:fail ${isObject.msg}` }
|
|
59
|
-
console.error(res.errMsg)
|
|
60
|
-
return Promise.reject(res)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const { animation, success, fail, complete } = options
|
|
64
|
-
const handle = new MethodHandler({ name: 'showTabBar', success, fail, complete })
|
|
65
|
-
|
|
66
|
-
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
67
|
-
return handle.fail({
|
|
68
|
-
errMsg: getParameterError({
|
|
69
|
-
para: 'animation',
|
|
70
|
-
correct: 'Boolean',
|
|
71
|
-
wrong: animation
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
78
|
-
animation,
|
|
79
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
80
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 动态设置 tabBar 的整体样式
|
|
87
|
-
*/
|
|
88
|
-
export const setTabBarStyle: typeof Taro.setTabBarStyle = (options = {}) => {
|
|
89
|
-
// options must be an Object
|
|
90
|
-
const isObject = shouldBeObject(options)
|
|
91
|
-
if (!isObject.flag) {
|
|
92
|
-
const res = { errMsg: `setTabBarStyle:fail ${isObject.msg}` }
|
|
93
|
-
console.error(res.errMsg)
|
|
94
|
-
return Promise.reject(res)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { color, selectedColor, backgroundColor, borderStyle, success, fail, complete } = options
|
|
98
|
-
const handle = new MethodHandler({ name: 'setTabBarStyle', success, fail, complete })
|
|
99
|
-
|
|
100
|
-
let errMsg
|
|
101
|
-
if (color && !isValidColor(color)) {
|
|
102
|
-
errMsg = 'color'
|
|
103
|
-
} else if (selectedColor && !isValidColor(selectedColor)) {
|
|
104
|
-
errMsg = 'selectedColor'
|
|
105
|
-
} else if (backgroundColor && !isValidColor(backgroundColor)) {
|
|
106
|
-
errMsg = 'backgroundColor'
|
|
107
|
-
} else if (borderStyle && !/^(black|white)$/.test(borderStyle)) {
|
|
108
|
-
errMsg = 'borderStyle'
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (errMsg) {
|
|
112
|
-
return handle.fail({ errMsg: `invalid ${errMsg}` })
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!tabConf) {
|
|
116
|
-
return handle.fail()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const obj: Taro.setTabBarStyle.Option = {}
|
|
120
|
-
if (color) obj.color = color
|
|
121
|
-
if (selectedColor) obj.selectedColor = selectedColor
|
|
122
|
-
if (backgroundColor) obj.backgroundColor = backgroundColor
|
|
123
|
-
if (borderStyle) obj.borderStyle = borderStyle
|
|
124
|
-
|
|
125
|
-
return new Promise((resolve, reject) => {
|
|
126
|
-
Taro.eventCenter.trigger('__taroSetTabBarStyle', {
|
|
127
|
-
color,
|
|
128
|
-
selectedColor,
|
|
129
|
-
backgroundColor,
|
|
130
|
-
borderStyle,
|
|
131
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
132
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 动态设置 tabBar 某一项的内容
|
|
139
|
-
*/
|
|
140
|
-
export const setTabBarItem: typeof Taro.setTabBarItem = (options) => {
|
|
141
|
-
// options must be an Object
|
|
142
|
-
const isObject = shouldBeObject(options)
|
|
143
|
-
if (!isObject.flag) {
|
|
144
|
-
const res = { errMsg: `setTabBarItem:fail ${isObject.msg}` }
|
|
145
|
-
console.error(res.errMsg)
|
|
146
|
-
return Promise.reject(res)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const {
|
|
150
|
-
index,
|
|
151
|
-
text,
|
|
152
|
-
iconPath,
|
|
153
|
-
selectedIconPath,
|
|
154
|
-
success,
|
|
155
|
-
fail,
|
|
156
|
-
complete
|
|
157
|
-
} = options
|
|
158
|
-
const handle = new MethodHandler({ name: 'setTabBarItem', success, fail, complete })
|
|
159
|
-
|
|
160
|
-
if (typeof index !== 'number') {
|
|
161
|
-
return handle.fail({
|
|
162
|
-
errMsg: getParameterError({
|
|
163
|
-
para: 'index',
|
|
164
|
-
correct: 'Number',
|
|
165
|
-
wrong: index
|
|
166
|
-
})
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return new Promise((resolve, reject) => {
|
|
171
|
-
Taro.eventCenter.trigger('__taroSetTabBarItem', {
|
|
172
|
-
index,
|
|
173
|
-
text,
|
|
174
|
-
iconPath,
|
|
175
|
-
selectedIconPath,
|
|
176
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
177
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* 为 tabBar 某一项的右上角添加文本
|
|
184
|
-
*/
|
|
185
|
-
export const setTabBarBadge: typeof Taro.setTabBarBadge = (options) => {
|
|
186
|
-
// options must be an Object
|
|
187
|
-
const isObject = shouldBeObject(options)
|
|
188
|
-
if (!isObject.flag) {
|
|
189
|
-
const res = { errMsg: `setTabBarBadge:fail ${isObject.msg}` }
|
|
190
|
-
console.error(res.errMsg)
|
|
191
|
-
return Promise.reject(res)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const { index, text, success, fail, complete } = options
|
|
195
|
-
const handle = new MethodHandler({ name: 'setTabBarBadge', success, fail, complete })
|
|
196
|
-
|
|
197
|
-
if (typeof index !== 'number') {
|
|
198
|
-
return handle.fail({
|
|
199
|
-
errMsg: getParameterError({
|
|
200
|
-
para: 'index',
|
|
201
|
-
correct: 'Number',
|
|
202
|
-
wrong: index
|
|
203
|
-
})
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (typeof text !== 'string') {
|
|
208
|
-
return handle.fail({
|
|
209
|
-
errMsg: getParameterError({
|
|
210
|
-
para: 'text',
|
|
211
|
-
correct: 'String',
|
|
212
|
-
wrong: text
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return new Promise((resolve, reject) => {
|
|
218
|
-
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
219
|
-
index,
|
|
220
|
-
text,
|
|
221
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
222
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* 移除 tabBar 某一项右上角的文本
|
|
229
|
-
*/
|
|
230
|
-
export const removeTabBarBadge: typeof Taro.removeTabBarBadge = (options) => {
|
|
231
|
-
// options must be an Object
|
|
232
|
-
const isObject = shouldBeObject(options)
|
|
233
|
-
if (!isObject.flag) {
|
|
234
|
-
const res = { errMsg: `removeTabBarBadge:fail ${isObject.msg}` }
|
|
235
|
-
console.error(res.errMsg)
|
|
236
|
-
return Promise.reject(res)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const { index, success, fail, complete } = options
|
|
240
|
-
const handle = new MethodHandler({ name: 'removeTabBarBadge', success, fail, complete })
|
|
241
|
-
|
|
242
|
-
if (typeof index !== 'number') {
|
|
243
|
-
return handle.fail({
|
|
244
|
-
errMsg: getParameterError({
|
|
245
|
-
para: 'index',
|
|
246
|
-
correct: 'Number',
|
|
247
|
-
wrong: index
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return new Promise((resolve, reject) => {
|
|
253
|
-
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
254
|
-
index,
|
|
255
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
256
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
257
|
-
})
|
|
258
|
-
})
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* 隐藏 tabBar 某一项的右上角的红点
|
|
263
|
-
*/
|
|
264
|
-
export const hideTabBarRedDot: typeof Taro.hideTabBarRedDot = (options) => {
|
|
265
|
-
// options must be an Object
|
|
266
|
-
const isObject = shouldBeObject(options)
|
|
267
|
-
if (!isObject.flag) {
|
|
268
|
-
const res = { errMsg: `hideTabBarRedDot:fail ${isObject.msg}` }
|
|
269
|
-
console.error(res.errMsg)
|
|
270
|
-
return Promise.reject(res)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const { index, success, fail, complete } = options
|
|
274
|
-
const handle = new MethodHandler({ name: 'hideTabBarRedDot', success, fail, complete })
|
|
275
|
-
|
|
276
|
-
if (typeof index !== 'number') {
|
|
277
|
-
return handle.fail({
|
|
278
|
-
errMsg: getParameterError({
|
|
279
|
-
para: 'index',
|
|
280
|
-
correct: 'Number',
|
|
281
|
-
wrong: index
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return new Promise((resolve, reject) => {
|
|
287
|
-
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
288
|
-
index,
|
|
289
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
290
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
291
|
-
})
|
|
292
|
-
})
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* 隐藏 tabBar
|
|
297
|
-
*/
|
|
298
|
-
export const hideTabBar: typeof Taro.hideTabBar = (options = {}) => {
|
|
299
|
-
// options must be an Object
|
|
300
|
-
const isObject = shouldBeObject(options)
|
|
301
|
-
if (!isObject.flag) {
|
|
302
|
-
const res = { errMsg: `hideTabBar:fail ${isObject.msg}` }
|
|
303
|
-
console.error(res.errMsg)
|
|
304
|
-
return Promise.reject(res)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
const { animation, success, fail, complete } = options
|
|
308
|
-
const handle = new MethodHandler({ name: 'hideTabBar', success, fail, complete })
|
|
309
|
-
|
|
310
|
-
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
311
|
-
return handle.fail({
|
|
312
|
-
errMsg: getParameterError({
|
|
313
|
-
para: 'animation',
|
|
314
|
-
correct: 'Boolean',
|
|
315
|
-
wrong: animation
|
|
316
|
-
})
|
|
317
|
-
})
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return new Promise((resolve, reject) => {
|
|
321
|
-
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
322
|
-
animation,
|
|
323
|
-
successHandler: (res = {}) => handle.success(res, resolve as any),
|
|
324
|
-
errorHandler: (res = {}) => handle.fail(res, reject as any)
|
|
325
|
-
})
|
|
326
|
-
})
|
|
327
|
-
}
|
package/src/api/ui/window.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
-
import { CallbackManager } from '../../utils/handler'
|
|
5
|
-
|
|
6
|
-
const callbackManager = new CallbackManager()
|
|
7
|
-
|
|
8
|
-
const resizeListener = () => {
|
|
9
|
-
callbackManager.trigger({
|
|
10
|
-
windowWidth: window.screen.width,
|
|
11
|
-
windowHeight: window.screen.height
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
17
|
-
*/
|
|
18
|
-
export const setWindowSize = temporarilyNotSupport('setWindowSize')
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 监听窗口尺寸变化事件
|
|
22
|
-
*/
|
|
23
|
-
export const onWindowResize: typeof Taro.onWindowResize = callback => {
|
|
24
|
-
callbackManager.add(callback)
|
|
25
|
-
if (callbackManager.count() === 1) {
|
|
26
|
-
window.addEventListener('resize', resizeListener)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 取消监听窗口尺寸变化事件
|
|
32
|
-
*/
|
|
33
|
-
export const offWindowResize: typeof Taro.offWindowResize = callback => {
|
|
34
|
-
callbackManager.remove(callback)
|
|
35
|
-
if (callbackManager.count() === 0) {
|
|
36
|
-
window.removeEventListener('resize', resizeListener)
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/api/worker/index.ts
DELETED
package/src/api/wxml/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
-
import { SelectorQuery } from './selectorQuery'
|
|
5
|
-
|
|
6
|
-
export const createSelectorQuery: typeof Taro.createSelectorQuery = () => {
|
|
7
|
-
return new SelectorQuery()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver')
|
package/src/api/wxml/nodesRef.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { SelectorQuery } from './selectorQuery'
|
|
2
|
-
|
|
3
|
-
export class NodesRef implements Taro.NodesRef {
|
|
4
|
-
_component?: TaroGeneral.IAnyObject
|
|
5
|
-
_selector: string
|
|
6
|
-
_selectorQuery: SelectorQuery
|
|
7
|
-
_single: boolean
|
|
8
|
-
|
|
9
|
-
constructor (selector: string, querySelectorQuery: SelectorQuery, single: boolean) {
|
|
10
|
-
this._component = querySelectorQuery._component
|
|
11
|
-
this._selector = selector
|
|
12
|
-
this._selectorQuery = querySelectorQuery
|
|
13
|
-
this._single = single
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
context (cb) {
|
|
17
|
-
const { _selector, _component, _single, _selectorQuery } = this
|
|
18
|
-
_selectorQuery._push(_selector, _component, _single, { context: !0 }, cb)
|
|
19
|
-
return _selectorQuery
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
node (cb) {
|
|
23
|
-
const { _selector, _component, _single, _selectorQuery } = this
|
|
24
|
-
_selectorQuery._push(_selector, _component, _single, { nodeCanvasType: !0, node: !0 }, cb)
|
|
25
|
-
return _selectorQuery
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
boundingClientRect (cb) {
|
|
29
|
-
const { _selector, _component, _single, _selectorQuery } = this
|
|
30
|
-
_selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, rect: !0, size: !0 }, cb)
|
|
31
|
-
return _selectorQuery
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
scrollOffset (cb) {
|
|
35
|
-
const { _selector, _component, _single, _selectorQuery } = this
|
|
36
|
-
_selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, scrollOffset: !0 }, cb)
|
|
37
|
-
return _selectorQuery
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fields (fields, cb) {
|
|
41
|
-
const { _selector, _component, _single, _selectorQuery } = this
|
|
42
|
-
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields
|
|
43
|
-
|
|
44
|
-
_selectorQuery._push(_selector, _component, _single, {
|
|
45
|
-
id,
|
|
46
|
-
dataset,
|
|
47
|
-
rect,
|
|
48
|
-
size,
|
|
49
|
-
scrollOffset,
|
|
50
|
-
properties,
|
|
51
|
-
computedStyle
|
|
52
|
-
}, cb)
|
|
53
|
-
|
|
54
|
-
return _selectorQuery
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { findDOM } from '../../utils'
|
|
4
|
-
import { CanvasContext } from '../canvas/CanvasContext'
|
|
5
|
-
import { NodesRef } from './nodesRef'
|
|
6
|
-
|
|
7
|
-
type TElement = Document | HTMLElement | Element
|
|
8
|
-
|
|
9
|
-
interface ISelectorQueryQueue {
|
|
10
|
-
component: TaroGeneral.IAnyObject
|
|
11
|
-
selector: string
|
|
12
|
-
single: boolean
|
|
13
|
-
fields
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type TSelectorQueryQueueCallback = (res: ISelectorQueryQueue) => void
|
|
17
|
-
|
|
18
|
-
function filter (fields, dom?: HTMLElement, selector?: string) {
|
|
19
|
-
if (!dom) return null
|
|
20
|
-
|
|
21
|
-
const isViewport = selector === '.taro_page'
|
|
22
|
-
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [], nodeCanvasType, node, context } = fields
|
|
23
|
-
const res: any = {}
|
|
24
|
-
|
|
25
|
-
if (nodeCanvasType && node) {
|
|
26
|
-
const tagName = dom.tagName
|
|
27
|
-
res.node = {
|
|
28
|
-
id: dom.id,
|
|
29
|
-
$taroElement: dom
|
|
30
|
-
}
|
|
31
|
-
if (/^taro-canvas-core/i.test(tagName)) {
|
|
32
|
-
const type = (dom as any).type! || ''
|
|
33
|
-
res.nodeCanvasType = type
|
|
34
|
-
const canvas = dom.getElementsByTagName('canvas')[0]
|
|
35
|
-
if (/^(2d|webgl)/i.test(type) && canvas) {
|
|
36
|
-
res.node = canvas
|
|
37
|
-
} else {
|
|
38
|
-
res.node = null
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
// TODO https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
|
|
42
|
-
// if (/^taro-scroll-view-core/i.test(tagName))
|
|
43
|
-
res.nodeCanvasType = ''
|
|
44
|
-
res.node = dom
|
|
45
|
-
}
|
|
46
|
-
return res
|
|
47
|
-
}
|
|
48
|
-
if (context) {
|
|
49
|
-
const tagName = dom.tagName
|
|
50
|
-
if (/^taro-video-core/i.test(tagName)) {
|
|
51
|
-
// TODO HTMLVideoElement to VideoContext
|
|
52
|
-
return { context: dom as unknown as Taro.VideoContext }
|
|
53
|
-
} else if (/^taro-canvas-core/i.test(tagName)) {
|
|
54
|
-
const type = (dom as any).type! || '2d'
|
|
55
|
-
const canvas = dom?.querySelector('canvas') as HTMLCanvasElement
|
|
56
|
-
const ctx = canvas?.getContext(type) as CanvasRenderingContext2D
|
|
57
|
-
return { context: new CanvasContext(canvas, ctx) }
|
|
58
|
-
} else if (/^taro-live-player-core/i.test(tagName)) {
|
|
59
|
-
console.error('暂时不支持通过 NodesRef.context 获取 LivePlayerContext')
|
|
60
|
-
} else if (/^taro-editor-core/i.test(tagName)) {
|
|
61
|
-
console.error('暂时不支持通过 NodesRef.context 获取 EditorContext')
|
|
62
|
-
} else if (/^taro-map-core/i.test(tagName)) {
|
|
63
|
-
console.error('暂时不支持通过 NodesRef.context 获取 MapContext')
|
|
64
|
-
}
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
if (id) res.id = dom.id
|
|
68
|
-
if (dataset) res.dataset = Object.assign({}, dom.dataset)
|
|
69
|
-
if (rect || size) {
|
|
70
|
-
const { left, right, top, bottom, width, height } = dom.getBoundingClientRect()
|
|
71
|
-
if (rect) {
|
|
72
|
-
if (!isViewport) {
|
|
73
|
-
res.left = left
|
|
74
|
-
res.right = right
|
|
75
|
-
res.top = top
|
|
76
|
-
res.bottom = bottom
|
|
77
|
-
} else {
|
|
78
|
-
res.left = 0
|
|
79
|
-
res.right = 0
|
|
80
|
-
res.top = 0
|
|
81
|
-
res.bottom = 0
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (size) {
|
|
85
|
-
if (!isViewport) {
|
|
86
|
-
res.width = width
|
|
87
|
-
res.height = height
|
|
88
|
-
} else {
|
|
89
|
-
res.width = dom.clientWidth
|
|
90
|
-
res.height = dom.clientHeight
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (scrollOffset) {
|
|
95
|
-
res.scrollLeft = dom.scrollLeft
|
|
96
|
-
res.scrollTop = dom.scrollTop
|
|
97
|
-
}
|
|
98
|
-
if (properties.length) {
|
|
99
|
-
properties.forEach(prop => {
|
|
100
|
-
const attr = dom.getAttribute(prop)
|
|
101
|
-
if (attr) res[prop] = attr
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
if (computedStyle.length) {
|
|
105
|
-
const styles = window.getComputedStyle(dom)
|
|
106
|
-
computedStyle.forEach(key => {
|
|
107
|
-
const value = styles.getPropertyValue(key) || styles[key]
|
|
108
|
-
if (value) res[key] = value
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return res
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* WXML节点信息API
|
|
117
|
-
* @return {Object} SelectorQuery 对象实例
|
|
118
|
-
*/
|
|
119
|
-
function queryBat (queue: ISelectorQueryQueue[], cb: (...args: any[]) => any): void {
|
|
120
|
-
const result: any[] = []
|
|
121
|
-
|
|
122
|
-
queue.forEach(item => {
|
|
123
|
-
const { selector, single, fields, component } = item
|
|
124
|
-
// selector 的容器节点
|
|
125
|
-
/* eslint-disable */
|
|
126
|
-
const container: TElement = (
|
|
127
|
-
component !== null ?
|
|
128
|
-
(findDOM(component) as HTMLElement || document) :
|
|
129
|
-
document
|
|
130
|
-
)
|
|
131
|
-
/* eslint-enable */
|
|
132
|
-
|
|
133
|
-
// 特殊处理 ---- 选自己
|
|
134
|
-
let selectSelf = false
|
|
135
|
-
if (container !== document) {
|
|
136
|
-
const $nodeList = container.parentNode?.querySelectorAll(selector)
|
|
137
|
-
if ($nodeList) {
|
|
138
|
-
for (let i = 0, len = $nodeList.length; i < len; ++i) {
|
|
139
|
-
if (container === $nodeList[i]) {
|
|
140
|
-
selectSelf = true
|
|
141
|
-
break
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (single) {
|
|
148
|
-
const el = selectSelf === true ? container : container.querySelector(selector)
|
|
149
|
-
result.push(filter(fields, el as HTMLElement, selector))
|
|
150
|
-
} else {
|
|
151
|
-
const $children = container.querySelectorAll(selector)
|
|
152
|
-
const children: TElement[] = []
|
|
153
|
-
selectSelf === true && children.push(container)
|
|
154
|
-
for (let i = 0, len = $children.length; i < len; ++i) {
|
|
155
|
-
children.push($children[i])
|
|
156
|
-
}
|
|
157
|
-
result.push(children.map(dom => filter(fields, dom as HTMLElement)))
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
cb(result)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export class SelectorQuery implements Taro.SelectorQuery {
|
|
164
|
-
_defaultWebviewId: string | null
|
|
165
|
-
_webviewId: string | null
|
|
166
|
-
_queue: ISelectorQueryQueue[]
|
|
167
|
-
_queueCb: (TSelectorQueryQueueCallback | null)[]
|
|
168
|
-
_component?: TaroGeneral.IAnyObject
|
|
169
|
-
|
|
170
|
-
constructor () {
|
|
171
|
-
this._defaultWebviewId = null
|
|
172
|
-
this._webviewId = null
|
|
173
|
-
this._queue = []
|
|
174
|
-
this._queueCb = []
|
|
175
|
-
this._component
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
in (component: TaroGeneral.IAnyObject) {
|
|
179
|
-
this._component = component
|
|
180
|
-
return this
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
select (selector: string) {
|
|
184
|
-
// 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>'
|
|
185
|
-
if (typeof selector === 'string') selector = selector.replace('>>>', '>')
|
|
186
|
-
return new NodesRef(selector, this, true)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
selectAll (selector: string) {
|
|
190
|
-
// 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>'
|
|
191
|
-
if (typeof selector === 'string') selector = selector.replace('>>>', '>')
|
|
192
|
-
return new NodesRef(selector, this, false)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
selectViewport () {
|
|
196
|
-
return new NodesRef('.taro_page', this, true)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
exec (cb) {
|
|
200
|
-
queryBat(this._queue, res => {
|
|
201
|
-
const _queueCb = this._queueCb
|
|
202
|
-
res.forEach((item, index) => {
|
|
203
|
-
const cb = _queueCb[index]
|
|
204
|
-
typeof cb === 'function' && cb.call(this, item)
|
|
205
|
-
})
|
|
206
|
-
typeof cb === 'function' && cb.call(this, res)
|
|
207
|
-
})
|
|
208
|
-
return this as unknown as Taro.NodesRef
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
_push (selector: string, component, single, fields, callback: TSelectorQueryQueueCallback | null = null) {
|
|
212
|
-
this._queue.push({
|
|
213
|
-
component,
|
|
214
|
-
selector,
|
|
215
|
-
single,
|
|
216
|
-
fields
|
|
217
|
-
})
|
|
218
|
-
this._queueCb.push(callback)
|
|
219
|
-
}
|
|
220
|
-
}
|
package/src/index.ts
DELETED
package/src/utils/animation.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ease-in-out的函数
|
|
3
|
-
* @param t 0-1的数字
|
|
4
|
-
*/
|
|
5
|
-
export const easeInOut = (t: number) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1)
|
|
6
|
-
|
|
7
|
-
export const getTimingFunc = (easeFunc, frameCnt) => {
|
|
8
|
-
return x => {
|
|
9
|
-
if (frameCnt <= 1) {
|
|
10
|
-
return easeFunc(1)
|
|
11
|
-
}
|
|
12
|
-
const t = x / (frameCnt - 1)
|
|
13
|
-
return easeFunc(t)
|
|
14
|
-
}
|
|
15
|
-
}
|