From ec0773ab93f2bec07351537e0331367037cd005d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 30 Jul 2019 23:49:21 +0100 Subject: [PATCH] Removed Input class --- plugins/spine/src/runtimes/spine-both.js | 189 ----------------------- 1 file changed, 189 deletions(-) diff --git a/plugins/spine/src/runtimes/spine-both.js b/plugins/spine/src/runtimes/spine-both.js index ccf49d91f..2eb885562 100644 --- a/plugins/spine/src/runtimes/spine-both.js +++ b/plugins/spine/src/runtimes/spine-both.js @@ -7256,195 +7256,6 @@ var spine; })(webgl = spine.webgl || (spine.webgl = {})); })(spine || (spine = {})); var spine; -(function (spine) { - var webgl; - (function (webgl) { - var Input = (function () { - function Input(element) { - this.lastX = 0; - this.lastY = 0; - this.buttonDown = false; - this.currTouch = null; - this.touchesPool = new spine.Pool(function () { - return new spine.webgl.Touch(0, 0, 0); - }); - this.listeners = new Array(); - this.element = element; - this.setupCallbacks(element); - } - Input.prototype.setupCallbacks = function (element) { - var _this = this; - var mouseDown = function (ev) { - if (ev instanceof MouseEvent) { - var rect = element.getBoundingClientRect(); - var x = ev.clientX - rect.left; - var y = ev.clientY - rect.top; - var listeners = _this.listeners; - for (var i = 0; i < listeners.length; i++) { - listeners[i].down(x, y); - } - _this.lastX = x; - _this.lastY = y; - _this.buttonDown = true; - document.addEventListener("mousemove", mouseMove); - document.addEventListener("mouseup", mouseUp); - } - }; - var mouseMove = function (ev) { - if (ev instanceof MouseEvent) { - var rect = element.getBoundingClientRect(); - var x = ev.clientX - rect.left; - var y = ev.clientY - rect.top; - var listeners = _this.listeners; - for (var i = 0; i < listeners.length; i++) { - if (_this.buttonDown) { - listeners[i].dragged(x, y); - } - else { - listeners[i].moved(x, y); - } - } - _this.lastX = x; - _this.lastY = y; - } - }; - var mouseUp = function (ev) { - if (ev instanceof MouseEvent) { - var rect = element.getBoundingClientRect(); - var x = ev.clientX - rect.left; - var y = ev.clientY - rect.top; - var listeners = _this.listeners; - for (var i = 0; i < listeners.length; i++) { - listeners[i].up(x, y); - } - _this.lastX = x; - _this.lastY = y; - _this.buttonDown = false; - document.removeEventListener("mousemove", mouseMove); - document.removeEventListener("mouseup", mouseUp); - } - }; - element.addEventListener("mousedown", mouseDown, true); - element.addEventListener("mousemove", mouseMove, true); - element.addEventListener("mouseup", mouseUp, true); - element.addEventListener("touchstart", function (ev) { - if (_this.currTouch != null) - return; - var touches = ev.changedTouches; - for (var i = 0; i < touches.length; i++) { - var touch = touches[i]; - var rect = element.getBoundingClientRect(); - var x = touch.clientX - rect.left; - var y = touch.clientY - rect.top; - _this.currTouch = _this.touchesPool.obtain(); - _this.currTouch.identifier = touch.identifier; - _this.currTouch.x = x; - _this.currTouch.y = y; - break; - } - var listeners = _this.listeners; - for (var i_16 = 0; i_16 < listeners.length; i_16++) { - listeners[i_16].down(_this.currTouch.x, _this.currTouch.y); - } - console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); - _this.lastX = _this.currTouch.x; - _this.lastY = _this.currTouch.y; - _this.buttonDown = true; - ev.preventDefault(); - }, false); - element.addEventListener("touchend", function (ev) { - var touches = ev.changedTouches; - for (var i = 0; i < touches.length; i++) { - var touch = touches[i]; - if (_this.currTouch.identifier === touch.identifier) { - var rect = element.getBoundingClientRect(); - var x = _this.currTouch.x = touch.clientX - rect.left; - var y = _this.currTouch.y = touch.clientY - rect.top; - _this.touchesPool.free(_this.currTouch); - var listeners = _this.listeners; - for (var i_17 = 0; i_17 < listeners.length; i_17++) { - listeners[i_17].up(x, y); - } - console.log("End " + x + ", " + y); - _this.lastX = x; - _this.lastY = y; - _this.buttonDown = false; - _this.currTouch = null; - break; - } - } - ev.preventDefault(); - }, false); - element.addEventListener("touchcancel", function (ev) { - var touches = ev.changedTouches; - for (var i = 0; i < touches.length; i++) { - var touch = touches[i]; - if (_this.currTouch.identifier === touch.identifier) { - var rect = element.getBoundingClientRect(); - var x = _this.currTouch.x = touch.clientX - rect.left; - var y = _this.currTouch.y = touch.clientY - rect.top; - _this.touchesPool.free(_this.currTouch); - var listeners = _this.listeners; - for (var i_18 = 0; i_18 < listeners.length; i_18++) { - listeners[i_18].up(x, y); - } - console.log("End " + x + ", " + y); - _this.lastX = x; - _this.lastY = y; - _this.buttonDown = false; - _this.currTouch = null; - break; - } - } - ev.preventDefault(); - }, false); - element.addEventListener("touchmove", function (ev) { - if (_this.currTouch == null) - return; - var touches = ev.changedTouches; - for (var i = 0; i < touches.length; i++) { - var touch = touches[i]; - if (_this.currTouch.identifier === touch.identifier) { - var rect = element.getBoundingClientRect(); - var x = touch.clientX - rect.left; - var y = touch.clientY - rect.top; - var listeners = _this.listeners; - for (var i_19 = 0; i_19 < listeners.length; i_19++) { - listeners[i_19].dragged(x, y); - } - console.log("Drag " + x + ", " + y); - _this.lastX = _this.currTouch.x = x; - _this.lastY = _this.currTouch.y = y; - break; - } - } - ev.preventDefault(); - }, false); - }; - Input.prototype.addListener = function (listener) { - this.listeners.push(listener); - }; - Input.prototype.removeListener = function (listener) { - var idx = this.listeners.indexOf(listener); - if (idx > -1) { - this.listeners.splice(idx, 1); - } - }; - return Input; - }()); - webgl.Input = Input; - var Touch = (function () { - function Touch(identifier, x, y) { - this.identifier = identifier; - this.x = x; - this.y = y; - } - return Touch; - }()); - webgl.Touch = Touch; - })(webgl = spine.webgl || (spine.webgl = {})); -})(spine || (spine = {})); -var spine; (function (spine) { var webgl; (function (webgl) {