()
| 431 | } |
| 432 | // Start button |
| 433 | createStartButton() { |
| 434 | const button = this.createElement("div"); |
| 435 | button.classList.add("ejs_start_button"); |
| 436 | let border = 0; |
| 437 | if (typeof this.config.backgroundImg === "string") { |
| 438 | button.classList.add("ejs_start_button_border"); |
| 439 | border = 1; |
| 440 | } |
| 441 | button.innerText = (typeof this.config.startBtnName === "string") ? this.config.startBtnName : this.localization("Start Game"); |
| 442 | if (this.config.alignStartButton == "top") { |
| 443 | button.style.bottom = "calc(100% - 20px)"; |
| 444 | } else if (this.config.alignStartButton == "center") { |
| 445 | button.style.bottom = "calc(50% + 22.5px + " + border + "px)"; |
| 446 | } |
| 447 | this.elements.parent.appendChild(button); |
| 448 | this.addEventListener(button, "touchstart", () => { |
| 449 | this.touch = true; |
| 450 | }) |
| 451 | this.addEventListener(button, "click", this.startButtonClicked.bind(this)); |
| 452 | if (this.config.startOnLoad === true) { |
| 453 | this.startButtonClicked(button); |
| 454 | } |
| 455 | setTimeout(() => { |
| 456 | this.callEvent("ready"); |
| 457 | }, 20); |
| 458 | } |
| 459 | startButtonClicked(e) { |
| 460 | this.callEvent("start-clicked"); |
| 461 | if (e.pointerType === "touch") { |
no test coverage detected