[adapters] 增加小游戏适配部分源码

This commit is contained in:
SmallMain
2024-10-16 17:12:08 +08:00
parent 887d4a96c9
commit 07bf3b7a96
345 changed files with 38447 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
export default class MouseEvent {
constructor() {
}
}

View File

@@ -0,0 +1,32 @@
import { noop } from '../util/index.js'
export default class TouchEvent {
touches = []
targetTouches = []
changedTouches = []
preventDefault = noop
stopPropagation = noop
constructor(type) {
this.type = type
this.target = window.canvas
this.currentTarget = window.canvas
}
}
function touchEventHandlerFactory(type) {
return (event) => {
const touchEvent = new TouchEvent(type)
touchEvent.touches = event.touches
touchEvent.targetTouches = Array.prototype.slice.call(event.touches)
touchEvent.changedTouches = event.changedTouches
touchEvent.timeStamp = event.timeStamp
document.dispatchEvent(touchEvent)
}
}
tt.onTouchStart(touchEventHandlerFactory('touchstart'))
tt.onTouchMove(touchEventHandlerFactory('touchmove'))
tt.onTouchEnd(touchEventHandlerFactory('touchend'))
tt.onTouchCancel(touchEventHandlerFactory('touchcancel'))

View File

@@ -0,0 +1,2 @@
export TouchEvent from './TouchEvent'
export MouseEvent from './MouseEvent'