mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
7d2db6770c
* [adjsut] rename jsb to ral ,add ovh jsb.js * [adjust] adjust * [adjust] adjust adapter * [adjust] update adapter * [adjust] updata adapter * [bug] fix cannot run in cocos play * [bug] fix vivo cannot run * [adjust]rename jsb.js to ral.js
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
const mgr = cc.internal.inputManager;
|
|
const canvasPosition = {
|
|
left: 0,
|
|
top: 0,
|
|
};
|
|
|
|
Object.defineProperties(canvasPosition, {
|
|
width: {
|
|
get() {
|
|
return window.innerWidth;
|
|
},
|
|
},
|
|
height: {
|
|
get() {
|
|
return window.innerHeight;
|
|
},
|
|
},
|
|
});
|
|
|
|
if (mgr) {
|
|
Object.assign(mgr, {
|
|
_updateCanvasBoundingRect() { },
|
|
|
|
registerSystemEvent(element) {
|
|
if (this._isRegisterEvent) return;
|
|
|
|
this._glView = cc.view;
|
|
let self = this;
|
|
|
|
//register touch event
|
|
let _touchEventsMap = {
|
|
onTouchStart: this.handleTouchesBegin,
|
|
onTouchMove: this.handleTouchesMove,
|
|
onTouchEnd: this.handleTouchesEnd,
|
|
onTouchCancel: this.handleTouchesCancel,
|
|
};
|
|
|
|
let registerTouchEvent = function (eventName) {
|
|
let handler = _touchEventsMap[eventName];
|
|
ral[eventName](function (event) {
|
|
if (!event.changedTouches) return;
|
|
handler.call(self, self.getTouchesByEvent(event, canvasPosition));
|
|
});
|
|
};
|
|
|
|
for (let eventName in _touchEventsMap) {
|
|
registerTouchEvent(eventName);
|
|
}
|
|
|
|
this._isRegisterEvent = true;
|
|
},
|
|
});
|
|
} |