Fertig für Android
This commit is contained in:
@@ -418,10 +418,14 @@ class SoundManager {
|
||||
return this.channels[channel];
|
||||
}
|
||||
|
||||
async play(channel, audioOrOptions) {
|
||||
async resume(){
|
||||
if (typeof this.context.resume === "function") {
|
||||
this.context.resume();
|
||||
return this.context.resume();
|
||||
}
|
||||
}
|
||||
|
||||
async play(channel, audioOrOptions) {
|
||||
this.resume();
|
||||
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
|
||||
if (Helper.isNull(audioOrOptions)) {
|
||||
audioOrOptions = {};
|
||||
|
||||
@@ -97,7 +97,7 @@ export class MenuSite extends WordRotatorBaseSite {
|
||||
}
|
||||
|
||||
async startLevelSite() {
|
||||
SoundManager.getInstance().context.resume();
|
||||
SoundManager.getInstance().resume();
|
||||
this.startSite(LevelSite, Promise.race([this.loadLevelPromise, new Promise(async resolve => {
|
||||
const db = WordRotatorDb.getInstance();
|
||||
let level = await db.loadNextLevel(LevelSite.RENDERER_TYPES);
|
||||
|
||||
@@ -17,10 +17,10 @@ export class ParentSegment extends Segment {
|
||||
ParentSegment.mouseDownTarget = e.targetTouches[0].target;
|
||||
ParentSegment.clickPosition = {x: e.targetTouches[0].pageX, y: e.targetTouches[0].pageY};
|
||||
}
|
||||
else if (Array.isArray(e.path) && e.path.length >= 1) {
|
||||
ParentSegment.mouseDownTarget = e.path[0];
|
||||
ParentSegment.clickPosition = null;
|
||||
}
|
||||
// else if (Array.isArray(e.path) && e.path.length >= 1) {
|
||||
// ParentSegment.mouseDownTarget = e.path[0];
|
||||
// ParentSegment.clickPosition = null;
|
||||
// }
|
||||
});
|
||||
window.addEventListener("touchend", (e) => {
|
||||
ParentSegment.mouseDownTarget = null;
|
||||
@@ -39,32 +39,49 @@ export class ParentSegment extends Segment {
|
||||
this.class = "rotate-0";
|
||||
this.rotatable = true;
|
||||
|
||||
this.userRotationDelta = 100;
|
||||
this.lastUserRotation = 0;
|
||||
|
||||
let self = this;
|
||||
this.touchendListener = function (e) {
|
||||
let now = new Date().getTime();
|
||||
|
||||
// console.log("touchendListener", e,now, self.lastUserRotation);
|
||||
let target = null;
|
||||
let position = null;
|
||||
|
||||
if (e.changedTouches.length >= 1) {
|
||||
target = document.elementFromPoint(e.changedTouches[0].pageX, e.changedTouches[0].pageY);
|
||||
position = {x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY};
|
||||
}
|
||||
else if (Array.isArray(e.path) && e.path.length >= 1) {
|
||||
target = e.path[0];
|
||||
}
|
||||
if (e.targetTouches.length === 0 && self.element.contains(ParentSegment.mouseDownTarget) && self.element.contains(target)) {
|
||||
self.getLevel().segmentClickedListener(self);
|
||||
self.rotate(ParentSegment.mouseDownTarget, target, ParentSegment.clickPosition, position);
|
||||
if (target != null && e.targetTouches.length === 0 && self.element.contains(ParentSegment.mouseDownTarget) && self.element.contains(target)) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (self.lastUserRotation+self.userRotationDelta > now){
|
||||
return;
|
||||
}
|
||||
self.getLevel().segmentClickedListener(self);
|
||||
self.rotate(ParentSegment.mouseDownTarget, target, ParentSegment.clickPosition, position);
|
||||
// console.log("touchendListener stopped event", e);
|
||||
|
||||
self.lastUserRotation = new Date().getTime();
|
||||
}
|
||||
};
|
||||
this.mouseupListener = function (e) {
|
||||
let now = new Date().getTime();
|
||||
// console.log("mouseupListener", e,now, self.lastUserRotation);
|
||||
|
||||
if (ParentSegment.mouseDownTarget !== null && self.element.contains(ParentSegment.mouseDownTarget) && self.element.contains(e.target)) {
|
||||
let position = {x: e.pageX, y: e.pageY};
|
||||
|
||||
self.getLevel().segmentClickedListener(self);
|
||||
self.rotate(ParentSegment.mouseDownTarget, e.target, ParentSegment.clickPosition, position);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (self.lastUserRotation+self.userRotationDelta > now){
|
||||
return;
|
||||
}
|
||||
self.getLevel().segmentClickedListener(self);
|
||||
self.rotate(ParentSegment.mouseDownTarget, e.target, ParentSegment.clickPosition, position);
|
||||
// console.log("mouseupListener stopped event", e);
|
||||
self.lastUserRotation = new Date().getTime();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user