|
|
@@ -5484,17 +5484,32 @@ export struct LocalMusic {
|
|
|
PanGesture(this.panOption)
|
|
|
.onActionUpdate((event?: GestureEvent) => {
|
|
|
if (event) {
|
|
|
- this.translateY = event.offsetY;
|
|
|
- if (this.translateY < 0) {
|
|
|
- this.translateY = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
+ // 只允许向下滑动,向上滑动时限制为0
|
|
|
+ this.translateY = Math.max(0, event.offsetY);
|
|
|
}
|
|
|
})
|
|
|
- .onActionEnd(() => {
|
|
|
- if (this.translateY > this.windowHeight / 2) {
|
|
|
- this.isShowPlay = false;
|
|
|
+ .onActionEnd((event?: GestureEvent) => {
|
|
|
+ // 使用更低的阈值和滑动速度判断
|
|
|
+ const minDistance = 100; // 最小滑动距离 100vp
|
|
|
+ const minVelocity = 500; // 最小滑动速度
|
|
|
+
|
|
|
+ // 获取滑动速度(如果可用)
|
|
|
+ const velocity = event?.velocityY || 0;
|
|
|
+
|
|
|
+ // 判断是否应该关闭:距离足够 或者 速度足够快
|
|
|
+ const shouldClose = this.translateY > minDistance || velocity > minVelocity;
|
|
|
+
|
|
|
+ if (shouldClose) {
|
|
|
+ // 添加关闭动画
|
|
|
+ this.getUIContext().animateTo({
|
|
|
+ duration: 300,
|
|
|
+ curve: Curve.Smooth
|
|
|
+ }, () => {
|
|
|
+ this.isShowPlay = false;
|
|
|
+ this.translateY = 0;
|
|
|
+ })
|
|
|
} else {
|
|
|
+ // 回弹动画
|
|
|
this.getUIContext().animateTo({
|
|
|
duration: 300,
|
|
|
curve: Curve.Smooth
|