[ts][player] Closes #1238, disable pause/play when controls are hidden via options.

This commit is contained in:
badlogic 2019-01-03 13:43:23 +01:00
parent 66689b3800
commit 1cf8a72e30
6 changed files with 25 additions and 19 deletions

View File

@ -10820,6 +10820,8 @@ var spine;
target = null;
}
else {
if (!_this.config.showControls)
return;
if (_this.paused)
_this.play();
else

File diff suppressed because one or more lines are too long

View File

@ -10157,6 +10157,8 @@ var spine;
target = null;
}
else {
if (!_this.config.showControls)
return;
if (_this.paused)
_this.play();
else

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,8 @@ body {
backgroundColor: "#cccccc",
viewport: {
debugRender: true,
}
},
showControls: false,
});
/*// Creates a new spine player with a transparent background,

View File

@ -989,6 +989,7 @@
if (target) {
target = null;
} else {
if (!this.config.showControls) return;
if (this.paused)
this.play()
else
@ -1048,22 +1049,22 @@
let handleHover = (mouseX: number, mouseY: number) => {
if (!this.config.showControls) return;
let popup = findWithClass(this.dom, "spine-player-popup");
mouseOverControls = overlap(mouseX, mouseY, this.playerControls.getBoundingClientRect());
mouseOverCanvas = overlap(mouseX, mouseY, this.canvas.getBoundingClientRect());
clearTimeout(this.cancelId);
let hide = popup.length == 0 && !mouseOverControls && !mouseOverCanvas && !this.paused;
if (hide) {
this.playerControls.classList.add("spine-player-controls-hidden");
} else {
this.playerControls.classList.remove("spine-player-controls-hidden");
}
if (!mouseOverControls && popup.length == 0 && !this.paused) {
let remove = () => {
if (!this.paused) this.playerControls.classList.add("spine-player-controls-hidden");
};
this.cancelId = setTimeout(remove, 1000);
}
let popup = findWithClass(this.dom, "spine-player-popup");
mouseOverControls = overlap(mouseX, mouseY, this.playerControls.getBoundingClientRect());
mouseOverCanvas = overlap(mouseX, mouseY, this.canvas.getBoundingClientRect());
clearTimeout(this.cancelId);
let hide = popup.length == 0 && !mouseOverControls && !mouseOverCanvas && !this.paused;
if (hide) {
this.playerControls.classList.add("spine-player-controls-hidden");
} else {
this.playerControls.classList.remove("spine-player-controls-hidden");
}
if (!mouseOverControls && popup.length == 0 && !this.paused) {
let remove = () => {
if (!this.paused) this.playerControls.classList.add("spine-player-controls-hidden");
};
this.cancelId = setTimeout(remove, 1000);
}
}
let overlap = (mouseX: number, mouseY: number, rect: DOMRect | ClientRect): boolean => {