@@ -78,11 +78,9 @@ module.exports.Component = registerComponent('look-controls', {
7878 this . onMouseDown = bind ( this . onMouseDown , this ) ;
7979 this . onMouseMove = bind ( this . onMouseMove , this ) ;
8080 this . onMouseUp = bind ( this . onMouseUp , this ) ;
81- if ( this . data . touchEnabled ) {
82- this . onTouchStart = bind ( this . onTouchStart , this ) ;
83- this . onTouchMove = bind ( this . onTouchMove , this ) ;
84- this . onTouchEnd = bind ( this . onTouchEnd , this ) ;
85- }
81+ this . onTouchStart = bind ( this . onTouchStart , this ) ;
82+ this . onTouchMove = bind ( this . onTouchMove , this ) ;
83+ this . onTouchEnd = bind ( this . onTouchEnd , this ) ;
8684 this . onExitVR = bind ( this . onExitVR , this ) ;
8785 } ,
8886
@@ -126,11 +124,9 @@ module.exports.Component = registerComponent('look-controls', {
126124 window . addEventListener ( 'mouseup' , this . onMouseUp , false ) ;
127125
128126 // Touch events.
129- if ( this . data . touchEnabled ) {
130- canvasEl . addEventListener ( 'touchstart' , this . onTouchStart ) ;
131- window . addEventListener ( 'touchmove' , this . onTouchMove ) ;
132- window . addEventListener ( 'touchend' , this . onTouchEnd ) ;
133- }
127+ canvasEl . addEventListener ( 'touchstart' , this . onTouchStart ) ;
128+ window . addEventListener ( 'touchmove' , this . onTouchMove ) ;
129+ window . addEventListener ( 'touchend' , this . onTouchEnd ) ;
134130 } ,
135131
136132 /**
@@ -149,11 +145,9 @@ module.exports.Component = registerComponent('look-controls', {
149145 canvasEl . removeEventListener ( 'mouseout' , this . onMouseUp ) ;
150146
151147 // Touch events.
152- if ( this . data . touchEnabled ) {
153- canvasEl . removeEventListener ( 'touchstart' , this . onTouchStart ) ;
154- canvasEl . removeEventListener ( 'touchmove' , this . onTouchMove ) ;
155- canvasEl . removeEventListener ( 'touchend' , this . onTouchEnd ) ;
156- }
148+ canvasEl . removeEventListener ( 'touchstart' , this . onTouchStart ) ;
149+ canvasEl . removeEventListener ( 'touchmove' , this . onTouchMove ) ;
150+ canvasEl . removeEventListener ( 'touchend' , this . onTouchEnd ) ;
157151 } ,
158152
159153 /**
@@ -318,7 +312,7 @@ module.exports.Component = registerComponent('look-controls', {
318312 * Register touch down to detect touch drag.
319313 */
320314 onTouchStart : function ( evt ) {
321- if ( evt . touches . length !== 1 ) { return ; }
315+ if ( evt . touches . length !== 1 || ! this . data . touchEnabled ) { return ; }
322316 this . touchStart = {
323317 x : evt . touches [ 0 ] . pageX ,
324318 y : evt . touches [ 0 ] . pageY
@@ -334,7 +328,7 @@ module.exports.Component = registerComponent('look-controls', {
334328 var deltaY ;
335329 var yawObject = this . yawObject ;
336330
337- if ( ! this . touchStarted ) { return ; }
331+ if ( ! this . touchStarted || ! this . data . touchEnabled ) { return ; }
338332
339333 deltaY = 2 * Math . PI * ( evt . touches [ 0 ] . pageX - this . touchStart . x ) / canvas . clientWidth ;
340334
0 commit comments