add mobile web compatibility

This commit is contained in:
王劲鹏 2020-01-04 15:02:39 +08:00 committed by osborn
parent 8f0457101c
commit 14a1cc3ef8
3 changed files with 39 additions and 8 deletions

View File

@ -4796,7 +4796,24 @@ var doric_web = (function (exports, axios, sandbox) {
build() { build() {
const ret = document.createElement('div'); const ret = document.createElement('div');
ret.ontouchstart = (event) => { ret.ontouchstart = (event) => {
console.log("ontouchstart: " + event); this.dragging = true;
this.lastX = event.targetTouches[0].clientX;
this.lastY = event.targetTouches[0].clientY;
};
ret.ontouchend = (event) => {
this.dragging = false;
};
ret.ontouchcancel = (event) => {
this.dragging = false;
};
ret.ontouchmove = (event) => {
if (this.dragging) {
this.offsetX += (event.targetTouches[0].clientX - this.lastX);
this.offsetY += (event.targetTouches[0].clientY - this.lastY);
this.callJSResponse(this.onDrag, this.offsetX, this.offsetY);
this.lastX = event.targetTouches[0].clientX;
this.lastY = event.targetTouches[0].clientY;
}
}; };
ret.onmousedown = (event) => { ret.onmousedown = (event) => {
this.dragging = true; this.dragging = true;
@ -4814,8 +4831,6 @@ var doric_web = (function (exports, axios, sandbox) {
}; };
ret.onmouseup = (event) => { ret.onmouseup = (event) => {
this.dragging = false; this.dragging = false;
this.lastX = event.x;
this.lastY = event.y;
}; };
ret.onmouseout = (event) => { ret.onmouseout = (event) => {
this.dragging = false; this.dragging = false;

File diff suppressed because one or more lines are too long

View File

@ -9,8 +9,27 @@ export class DoricDraggableNode extends DoricStackNode {
build() { build() {
const ret = document.createElement('div') const ret = document.createElement('div')
ret.ontouchstart = (event) => { ret.ontouchstart = (event) => {
console.log("ontouchstart: " + event) this.dragging = true
this.lastX = event.targetTouches[0].clientX
this.lastY = event.targetTouches[0].clientY
} }
ret.ontouchend = (event) => {
this.dragging = false
}
ret.ontouchcancel = (event) => {
this.dragging = false
}
ret.ontouchmove = (event) => {
if (this.dragging) {
this.offsetX += (event.targetTouches[0].clientX - this.lastX)
this.offsetY += (event.targetTouches[0].clientY - this.lastY)
this.callJSResponse(this.onDrag, this.offsetX, this.offsetY)
this.lastX = event.targetTouches[0].clientX
this.lastY = event.targetTouches[0].clientY
}
}
ret.onmousedown = (event) => { ret.onmousedown = (event) => {
this.dragging = true this.dragging = true
this.lastX = event.x this.lastX = event.x
@ -28,9 +47,6 @@ export class DoricDraggableNode extends DoricStackNode {
} }
ret.onmouseup = (event) => { ret.onmouseup = (event) => {
this.dragging = false this.dragging = false
this.lastX = event.x
this.lastY = event.y
} }
ret.onmouseout = (event) => { ret.onmouseout = (event) => {
this.dragging = false this.dragging = false