mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
fix(core): browser compatibility issue with TouchList api (#389)
This commit is contained in:
parent
2b87cce7fe
commit
7c376e3254
@ -1,6 +1,6 @@
|
|||||||
export namespace MouseTouchEvent {
|
export namespace MouseTouchEvent {
|
||||||
export const isTouchEvent = (event: TouchEvent | React.TouchEvent): event is TouchEvent =>
|
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 => {
|
export const touchToMouseEvent = (event: Event): MouseEvent | Event => {
|
||||||
if (!isTouchEvent(event as TouchEvent)) {
|
if (!isTouchEvent(event as TouchEvent)) {
|
||||||
|
|||||||
@ -1,14 +1 @@
|
|||||||
import 'reflect-metadata';
|
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|||||||
@ -1,14 +1 @@
|
|||||||
import 'reflect-metadata';
|
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user