Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): touch event browser copability (#9437)

Saul-Mirone8d269c838d62
diff --git a/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts b/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts
index e3d8a40d3e..2176a5bb6d 100644
--- a/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts
+++ b/blocksuite/affine/data-view/src/core/utils/wc-dnd/sensors/mouse.ts
@@ -74,8 +74,12 @@ export function hasViewportRelativeCoordinates(
return 'clientX' in event && 'clientY' in event;
}
+function isTouchEvent(event: Event): event is TouchEvent {
+ return 'TouchEvent' in globalThis && event instanceof TouchEvent;
+}
+
const getEventCoordinates = (event: Event) => {
- if (event instanceof TouchEvent) {
+ if (isTouchEvent(event)) {
if (event.touches && event.touches.length) {
const touch = event.touches[0];
if (!touch) return;