Skip to content

movable-view 长按后,ios会偶现无法触发change事件 #5383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
halo1416 opened this issue Apr 7, 2025 · 6 comments
Open

movable-view 长按后,ios会偶现无法触发change事件 #5383

halo1416 opened this issue Apr 7, 2025 · 6 comments
Assignees

Comments

@halo1416
Copy link

halo1416 commented Apr 7, 2025

发行方式

小程序

具体平台

ios真机基本都有这个问题,如ios18.3.1;微信开发者工具选择ios设备也能复现(但机率较小)

开发环境

Windows

项目创建方式

HBuilderX

依赖版本

HBuilder X 4.45

uni.getSystemInfo() 返回的部分信息:

  system: "iOS 10.0.1"
  ua: undefined
  uniCompileVersion: "4.45"
  uniCompilerVersion: "4.45"
  uniPlatform: "mp-weixin"
  uniRuntimeVersion: "4.45"
  version: "8.0.5"

问题描述

原本是想基于 movable-view 实现长按拖拽排序,但发现ios偶尔在拖拽时不会触发change事件;ps:movable-view拖动效果确实丝滑

重现步骤

<template>
	<view style="margin-top: 50px;" class="test-page">
    <movable-area>
				<movable-view direction="vertical"
        @touchstart="handleDragStart" @longpress="handleLongpress"
        @touchmove="handleTouchMove" @change="handleMoving"
        @touchend="handleDragEnd"
        >text</movable-view>
			</movable-area>
	</view>
</template>

<script>
	export default {
		components:{ },
		data() {
			return { }
		},
		onLoad() {
			
		},
    onPageScroll(event) {
      console.log('0-0-0-0-0-0-0-0-0-0-0-0-0-0-');
    },
		methods: {
      handleDragStart(event) {
        console.log('---1111---开始拖动', event);
      },
      handleLongpress(event) {
        console.log('---2222---长按事件', event);
      },
      handleTouchMove(event) {
        console.log('---3333---TouchMove事件', event);
      },
      handleMoving(event) {
        console.log('---4444---change事件', event);
      },
      handleDragEnd(event) {
        console.log('---5555---拖动结束', event);
      }
		}
	}
</script>

<style lang="scss" scoped>
.test-page {
  height: 100vh;
  overflow: auto;

  movable-view {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 150rpx;
		width: 150rpx;
		background-color: #007AFF;
		color: #fff;
	}

	movable-area {
		height: 100vh;
		width: 100%;
		background-color: #D8D8D8;
		overflow: hidden;
	}

}
</style>

正常逻辑来说:会依次触发 touchstart、longpress、touchmove、change和touchend 对应的事件,但在ios偶尔只会触发 touchmove 却不触发 change(其他事件会触发)

因为要基于 change 事件的返回值 event.detail = {x: x, y: y, source: source} 去计算元素的位置,不触发change的情况下,拖拽就无效了

期望行为

No response

实际行为

No response

截图或录屏

No response

@GRCmade
Copy link
Collaborator

GRCmade commented Apr 8, 2025

hello , 你是不是长按后没有拖动,所以才不会触发的,你看是不是下面这种效果

Image

@GRCmade GRCmade self-assigned this Apr 8, 2025
@halo1416
Copy link
Author

halo1416 commented Apr 8, 2025

是有拖动的,但是有两点需要注意,一是长按生效,即输出 ---2222---长按事件 后,其次就是最好使用ios真机测试,模拟器出现的机率较小

Image

@GRCmade
Copy link
Collaborator

GRCmade commented Apr 17, 2025

是有拖动的,但是有两点需要注意,一是长按生效,即输出 ---2222---长按事件 后,其次就是最好使用ios真机测试,模拟器出现的机率较小

Image

这是怎么触发的,提供一下复现步骤

@halo1416
Copy link
Author

就是上面我提供的代码,最好在ios真机上运行(模拟器出现机率比较小),然后:
长按拖拽元素,不要拖动,等待长按事件执行后(即输出 ---2222---长按事件 内容后),再进行拖拽

@GRCmade
Copy link
Collaborator

GRCmade commented Apr 17, 2025

就是上面我提供的代码,最好在ios真机上运行(模拟器出现机率比较小),然后: 长按拖拽元素,不要拖动,等待长按事件执行后(即输出 ---2222---长按事件 内容后),再进行拖拽

能复现这个问题,但是这个组件完全是微信提供的,uniapp上也没有做过更改,一般来说这个事件,也不应该受到影响,你可以尝试写一个微信原生项目看一下是否也有这个问题。

@halo1416
Copy link
Author

就是上面我提供的代码,最好在ios真机上运行(模拟器出现机率比较小),然后: 长按拖拽元素,不要拖动,等待长按事件执行后(即输出 ---2222---长按事件 内容后),再进行拖拽

能复现这个问题,但是这个组件完全是微信提供的,uniapp上也没有做过更改,一般来说这个事件,也不应该受到影响,你可以尝试写一个微信原生项目看一下是否也有这个问题。

好的,感谢!我有空了试一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants