@tarojs/plugin-platform-harmony-ets 4.0.0-beta.64 → 4.0.0-beta.65
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/apis/base/system.ts +25 -5
- package/dist/components-harmony-ets/movableView.ets +22 -7
- package/dist/runtime-ets/dom/element/movableView.ts +10 -6
- package/dist/runtime-utils.js +19 -5
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +19 -5
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
package/dist/apis/base/system.ts
CHANGED
|
@@ -27,6 +27,14 @@ let windowRect
|
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
29
|
display = _display.getDefaultDisplaySync()
|
|
30
|
+
|
|
31
|
+
setSafeArea({
|
|
32
|
+
top: statusBarHeight,
|
|
33
|
+
left: 0,
|
|
34
|
+
right: display.width,
|
|
35
|
+
bottom: navigationIndicatorRect?.top
|
|
36
|
+
})
|
|
37
|
+
|
|
30
38
|
// @ts-ignore
|
|
31
39
|
display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} }: _display.CutoutInfo = {}) => {
|
|
32
40
|
if (err?.code) {
|
|
@@ -38,14 +46,13 @@ let windowRect
|
|
|
38
46
|
const bottom = Math.min(display.height - waterfallDisplayAreaRects.bottom?.top, navigationIndicatorRect?.top)
|
|
39
47
|
const left = waterfallDisplayAreaRects.left?.left + waterfallDisplayAreaRects.left?.width
|
|
40
48
|
const right = display.width - waterfallDisplayAreaRects.right?.left
|
|
41
|
-
|
|
49
|
+
|
|
50
|
+
setSafeArea({
|
|
42
51
|
top,
|
|
43
|
-
bottom,
|
|
44
52
|
left,
|
|
45
53
|
right,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
54
|
+
bottom
|
|
55
|
+
})
|
|
49
56
|
})
|
|
50
57
|
} catch (e) {
|
|
51
58
|
console.error('Failed to get display', e)
|
|
@@ -53,6 +60,19 @@ let windowRect
|
|
|
53
60
|
})
|
|
54
61
|
})
|
|
55
62
|
|
|
63
|
+
|
|
64
|
+
function setSafeArea({ top, left, right, bottom }) {
|
|
65
|
+
safeArea = {
|
|
66
|
+
top,
|
|
67
|
+
bottom,
|
|
68
|
+
left,
|
|
69
|
+
right,
|
|
70
|
+
height: bottom - top,
|
|
71
|
+
width: right - left,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
56
76
|
/* 同步版本 */
|
|
57
77
|
export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
|
|
58
78
|
const res: any = {}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import type { TaroAny, TaroMovableViewElement } from '@tarojs/runtime'
|
|
1
|
+
import type { TaroAny, TaroMovableViewElement, TaroElement } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
4
|
|
|
5
5
|
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { isUndefined } from '@tarojs/shared'
|
|
7
7
|
|
|
8
|
+
function callTouchEventFnFromGesture(node: TaroElement, eventName: string, gestureEvent: GestureEvent) {
|
|
9
|
+
const touchFns = (node?.__listeners?.[eventName] || []) as Function[]
|
|
10
|
+
touchFns.forEach(fn => {
|
|
11
|
+
fn({
|
|
12
|
+
changedTouches: gestureEvent.fingerList.map(finger => ({
|
|
13
|
+
clientX: finger.globalX,
|
|
14
|
+
clientY: finger.globalY
|
|
15
|
+
}))
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
@Component
|
|
9
21
|
export default struct TaroMovableView {
|
|
10
22
|
@Builder customBuilder() {}
|
|
@@ -15,6 +27,12 @@ export default struct TaroMovableView {
|
|
|
15
27
|
aboutToAppear(): void {
|
|
16
28
|
if (this.node) {
|
|
17
29
|
this.node._instance = this
|
|
30
|
+
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
const x = this.node.getAttribute('x') ? +this.node.getAttribute('x') : 0
|
|
33
|
+
const y = this.node.getAttribute('y') ? +this.node.getAttribute('y') : 0
|
|
34
|
+
this.node.checkPositionBoundary({ x, y }, this.node.scaleValue)
|
|
35
|
+
}, 0)
|
|
18
36
|
}
|
|
19
37
|
}
|
|
20
38
|
|
|
@@ -47,19 +65,16 @@ export default struct TaroMovableView {
|
|
|
47
65
|
PanGesture({fingers:1}).onActionStart((e: GestureEvent) => {
|
|
48
66
|
|
|
49
67
|
this.node.startMove()
|
|
68
|
+
callTouchEventFnFromGesture(this.node, 'touchstart', e)
|
|
50
69
|
}).onActionUpdate((e: GestureEvent) => {
|
|
51
|
-
|
|
70
|
+
callTouchEventFnFromGesture(this.node, 'touchmove', e)
|
|
52
71
|
this.node.doMove({
|
|
53
72
|
x: e.offsetX,
|
|
54
73
|
y: e.offsetY
|
|
55
74
|
})
|
|
56
|
-
// 事件处理
|
|
57
|
-
const bindchange = this.node.getAttribute('bindchange')
|
|
58
|
-
if (typeof bindchange === 'function') {
|
|
59
|
-
}
|
|
60
75
|
|
|
61
76
|
}).onActionEnd(() => {
|
|
62
|
-
|
|
77
|
+
callTouchEventFnFromGesture(this.node, 'touchend', e)
|
|
63
78
|
this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
|
|
64
79
|
}),
|
|
65
80
|
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
@@ -80,8 +80,10 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
|
|
|
80
80
|
|
|
81
81
|
this.checkPositionBoundary(this.position, val)
|
|
82
82
|
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const scaleFns = this?.__listeners?.scale || []
|
|
84
|
+
scaleFns.forEach((fn) => {
|
|
85
|
+
fn({ ...this.position, scale: this.scaleValue })
|
|
86
|
+
})
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -124,10 +126,12 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
|
|
|
124
126
|
areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
|
|
125
127
|
)
|
|
126
128
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
|
|
130
|
+
const changeFns = this?.__listeners?.change || []
|
|
131
|
+
changeFns.forEach((fn) => {
|
|
132
|
+
fn({ x, y, source: 'touch' })
|
|
133
|
+
})
|
|
134
|
+
|
|
131
135
|
this.position = {
|
|
132
136
|
x: x,
|
|
133
137
|
y: y,
|
package/dist/runtime-utils.js
CHANGED
|
@@ -279,6 +279,12 @@ Current.contextPromise.then((context) => {
|
|
|
279
279
|
windowRect = mainWindow.getWindowProperties().windowRect;
|
|
280
280
|
try {
|
|
281
281
|
display$1 = _display.getDefaultDisplaySync();
|
|
282
|
+
setSafeArea({
|
|
283
|
+
top: statusBarHeight,
|
|
284
|
+
left: 0,
|
|
285
|
+
right: display$1.width,
|
|
286
|
+
bottom: navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top
|
|
287
|
+
});
|
|
282
288
|
// @ts-ignore
|
|
283
289
|
display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
|
|
284
290
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -290,14 +296,12 @@ Current.contextPromise.then((context) => {
|
|
|
290
296
|
const bottom = Math.min(display$1.height - ((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top), navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top);
|
|
291
297
|
const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
|
|
292
298
|
const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
|
|
293
|
-
|
|
299
|
+
setSafeArea({
|
|
294
300
|
top,
|
|
295
|
-
bottom,
|
|
296
301
|
left,
|
|
297
302
|
right,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
};
|
|
303
|
+
bottom
|
|
304
|
+
});
|
|
301
305
|
});
|
|
302
306
|
}
|
|
303
307
|
catch (e) {
|
|
@@ -305,6 +309,16 @@ Current.contextPromise.then((context) => {
|
|
|
305
309
|
}
|
|
306
310
|
});
|
|
307
311
|
});
|
|
312
|
+
function setSafeArea({ top, left, right, bottom }) {
|
|
313
|
+
safeArea = {
|
|
314
|
+
top,
|
|
315
|
+
bottom,
|
|
316
|
+
left,
|
|
317
|
+
right,
|
|
318
|
+
height: bottom - top,
|
|
319
|
+
width: right - left,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
308
322
|
/* 同步版本 */
|
|
309
323
|
const getSystemInfoSync = function () {
|
|
310
324
|
var _a, _b;
|