1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Prepare for the release on gamedistribution

This commit is contained in:
tobspr
2020-05-22 13:12:07 +02:00
parent b3a2e869d1
commit ab5462e140
32 changed files with 375 additions and 243 deletions

View File

@@ -38,6 +38,7 @@ export let clickDetectorGlobals = {
* targetOnly?: boolean,
* maxDistance?: number,
* clickSound?: string,
* preventClick?: boolean,
* }} ClickDetectorConstructorArgs
*/
@@ -55,6 +56,7 @@ export class ClickDetector {
* @param {boolean=} param1.targetOnly Whether to also accept clicks on child elements (e.target !== element)
* @param {number=} param1.maxDistance The maximum distance in pixels to accept clicks
* @param {string=} param1.clickSound Sound key to play on touchdown
* @param {boolean=} param1.preventClick Whether to prevent click events
*/
constructor(
element,
@@ -66,6 +68,7 @@ export class ClickDetector {
targetOnly = false,
maxDistance = MAX_MOVE_DISTANCE_PX,
clickSound = SOUNDS.uiClick,
preventClick = false,
}
) {
assert(element, "No element given!");
@@ -78,6 +81,7 @@ export class ClickDetector {
this.targetOnly = targetOnly;
this.clickSound = clickSound;
this.maxDistance = maxDistance;
this.preventClick = preventClick;
// Signals
this.click = new Signal();
@@ -128,6 +132,10 @@ export class ClickDetector {
this.element.removeEventListener("mousemove", this.handlerTouchMove, options);
}
if (this.preventClick) {
this.element.removeEventListener("click", this.handlerPreventClick, options);
}
this.click.removeAll();
this.touchstart.removeAll();
this.touchmove.removeAll();
@@ -142,6 +150,14 @@ export class ClickDetector {
// INTERNAL METHODS
/**
*
* @param {Event} event
*/
internalPreventClick(event) {
event.preventDefault();
}
/**
* Internal method to get the options to pass to an event listener
*/
@@ -164,6 +180,11 @@ export class ClickDetector {
this.handlerTouchMove = this.internalOnPointerMove.bind(this);
this.handlerTouchCancel = this.internalOnTouchCancel.bind(this);
if (this.preventClick) {
this.handlerPreventClick = this.internalPreventClick.bind(this);
element.addEventListener("click", this.handlerPreventClick, options);
}
element.addEventListener("touchstart", this.handlerTouchStart, options);
element.addEventListener("touchend", this.handlerTouchEnd, options);
element.addEventListener("touchcancel", this.handlerTouchCancel, options);

View File

@@ -101,6 +101,7 @@ export const globalConfig = {
// framePausesBetweenTicks: 40,
// testTranslations: true,
// enableEntityInspector: true,
testAds: true,
/* dev:end */
},