ソースを参照

fix(core): browser compatibility issue with TouchList api (#389)

Louis Young 7 ヶ月 前
コミット
7c376e3254

+ 1 - 1
packages/canvas-engine/core/src/core/utils/mouse-touch-event.ts

@@ -1,6 +1,6 @@
 export namespace MouseTouchEvent {
   export const isTouchEvent = (event: TouchEvent | React.TouchEvent): event is TouchEvent =>
-    event?.touches instanceof TouchList;
+    Array.isArray(event?.touches) && event.touches.length > 0;
 
   export const touchToMouseEvent = (event: Event): MouseEvent | Event => {
     if (!isTouchEvent(event as TouchEvent)) {

+ 0 - 13
packages/canvas-engine/core/vitest.setup.ts

@@ -1,14 +1 @@
 import 'reflect-metadata';
-
-Object.defineProperty(window, 'TouchList', {
-  value: class TouchList {
-    constructor(touches: Touch[] = []) {
-      touches.forEach((touch, index) => {
-        this[index] = touch;
-      });
-      Object.defineProperty(this, 'length', {
-        value: touches.length,
-      });
-    }
-  },
-});

+ 0 - 13
packages/canvas-engine/free-layout-core/vitest.setup.ts

@@ -1,14 +1 @@
 import 'reflect-metadata';
-
-Object.defineProperty(window, 'TouchList', {
-  value: class TouchList {
-    constructor(touches: Touch[] = []) {
-      touches.forEach((touch, index) => {
-        this[index] = touch;
-      });
-      Object.defineProperty(this, 'length', {
-        value: touches.length,
-      });
-    }
-  },
-});