Skip to content
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

为什么env里的pointerEventsSupported属性判断时要加上ua判断? #1103

Open
DI404N opened this issue Dec 2, 2024 · 2 comments
Open

Comments

@DI404N
Copy link

DI404N commented Dec 2, 2024

开发时遇到一个问题:
image
上面这段代码(模拟拖拽场景,因为要拖拽的元素很小,所以是给document监听mousemove事件)在Edge浏览器中,mousedown之后,如果不mouseup,mousemove事件不会触发,但是在Chrome中是正常的。在Chrome中e.event的类型是MouseEvent;而Edge中e.event的类型是PointerEvent,然后调用了e.stop取消了事件,导致了mousemove不会再被触发。
问题的根因是,zrender的env的代码中判断pointerEventsSupported要加上ua判断,限制pointerEventsSupported只有在edge和ie可用,为什么要这样写呢?
image

@plainheart
Copy link
Collaborator

应该是历史遗留问题,这个判断逻辑很早就是这样,不过原来有段注释,可供参考:

// (1) Firefox supports pointer but not by default, only MS browsers are reliable on pointer
// events currently. So we dont use that on other browsers unless tested sufficiently.
// For example, in iOS 13 Mobile Chromium 78, if the touching behavior starts page
// scroll, the pointermove event can not be fired any more. That will break some
// features like "pan horizontally to move something and pan vertically to page scroll".
// The horizontal pan probably be interrupted by the casually triggered page scroll.
// (2) Although IE 10 supports pointer event, it use old style and is different from the
// standard. So we exclude that. (IE 10 is hardly used on touch device)

@DI404N
Copy link
Author

DI404N commented Dec 13, 2024

有修复计划吗?

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