From 395034abfa36294632b2c9edd4087f6dd4cde7ac Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Tue, 8 May 2018 17:39:28 -0700 Subject: [PATCH] Fix the function binding I broke. --- src/components/cursor-controller.js | 37 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/cursor-controller.js b/src/components/cursor-controller.js index a121c44de..f50a67e21 100644 --- a/src/components/cursor-controller.js +++ b/src/components/cursor-controller.js @@ -41,24 +41,25 @@ AFRAME.registerComponent("cursor-controller", { this.data.cursor.setAttribute("material", { color: this.data.cursorColorUnhovered }); - [ - this._handleTouchStart, - this._handleTouchMove, - this._handleTouchEnd, - this._handleMouseDown, - this._handleMouseMove, - this._handleMouseUp, - this._handleWheel, - this._handleEnterVR, - this._handleExitVR, - this._handlePrimaryDown, - this._handlePrimaryUp, - this._handleModelLoaded, - this._handleCursorLoaded, - this._handleControllerConnected, - this._handleControllerDisconnected - ].forEach(fn => { - fn = fn.bind(this); + const functionNames = [ + "_handleTouchStart", + "_handleTouchMove", + "_handleTouchEnd", + "_handleMouseDown", + "_handleMouseMove", + "_handleMouseUp", + "_handleWheel", + "_handleEnterVR", + "_handleExitVR", + "_handlePrimaryDown", + "_handlePrimaryUp", + "_handleModelLoaded", + "_handleCursorLoaded", + "_handleControllerConnected", + "_handleControllerDisconnected" + ]; + functionNames.forEach(name => { + this[name] = this[name].bind(this); }); this.data.cursor.addEventListener("loaded", this._handleCursorLoaded); -- GitLab