Touchgesten implementiert
This commit is contained in:
@@ -3099,10 +3099,48 @@ class ScaleHelper {
|
||||
}
|
||||
|
||||
class ParentSegment extends Segment {
|
||||
static initListener(){
|
||||
window.addEventListener("mousedown", (e) => {
|
||||
ParentSegment.mouseDownTarget = e.originalTarget;
|
||||
});
|
||||
window.addEventListener("mouseup", (e) => {
|
||||
ParentSegment.mouseDownTarget = null;
|
||||
});
|
||||
|
||||
window.addEventListener("touchstart", (e) => {
|
||||
console.log("start", e);
|
||||
if (e.targetTouches.length === 1)
|
||||
{
|
||||
ParentSegment.mouseDownTarget = e.targetTouches[0].target;
|
||||
}
|
||||
});
|
||||
window.addEventListener("touchend", (e) => {
|
||||
console.log("end", e);
|
||||
ParentSegment.mouseDownTarget = null;
|
||||
});
|
||||
}
|
||||
|
||||
constructor(element) {
|
||||
super(element);
|
||||
this.children = [];
|
||||
this.class = "rotate-0";
|
||||
|
||||
let self = this;
|
||||
this.touchendListener = function(e){
|
||||
if (e.targetTouches.length === 0 && e.changedTouches.length === 1 && self.element.contains(ParentSegment.mouseDownTarget) && self.element.contains(document.elementFromPoint(e.changedTouches[0].pageX, e.changedTouches[0].pageY)))
|
||||
{
|
||||
console.log(e);
|
||||
self.rotate();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
this.mouseupListener = function(e){
|
||||
if (ParentSegment.mouseDownTarget !== null && self.element.contains(ParentSegment.mouseDownTarget) && self.element.contains(e.originalTarget))
|
||||
{
|
||||
self.rotate();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async rotate() {
|
||||
@@ -3197,12 +3235,16 @@ class ParentSegment extends Segment {
|
||||
childContainer.removeAllChildren();
|
||||
|
||||
this._updateRotationClass();
|
||||
// this.element.onclick = function (e) {
|
||||
// self.rotate();
|
||||
// e.stopPropagation();
|
||||
// };
|
||||
|
||||
const self = this;
|
||||
this.element.onclick = function (e) {
|
||||
self.rotate();
|
||||
e.stopPropagation();
|
||||
};
|
||||
this.element.removeEventListener("mouseup",this.mouseupListener);
|
||||
this.element.removeEventListener("touchend",this.touchendListener);
|
||||
|
||||
this.element.addEventListener("mouseup", this.mouseupListener);
|
||||
this.element.addEventListener("touchend", this.touchendListener);
|
||||
|
||||
for (let i = 0, n = this.children.length; i < n; i++) {
|
||||
this.children[i]._updateElement();
|
||||
@@ -3213,6 +3255,7 @@ class ParentSegment extends Segment {
|
||||
}
|
||||
}
|
||||
}
|
||||
ParentSegment.initListener();
|
||||
|
||||
class LeafSegment extends Segment {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user