Browse Source

fix for touch devices

Lewy Blue 6 years ago
parent
commit
7cf3f82f9a
1 changed files with 5 additions and 3 deletions
  1. 5 3
      examples/webgl_multiple_scenes_comparison.html

+ 5 - 3
examples/webgl_multiple_scenes_comparison.html

@@ -178,7 +178,7 @@
 
 
 					sliderMoved = true;
 					sliderMoved = true;
 
 
-					sliderPos = e.pageX;
+					sliderPos = e.pageX || e.touches[ 0 ].pageX;
 
 
 					//prevent the slider from being positioned outside the window bounds
 					//prevent the slider from being positioned outside the window bounds
 					if ( sliderPos < 0 ) sliderPos = 0;
 					if ( sliderPos < 0 ) sliderPos = 0;
@@ -189,9 +189,11 @@
 				}
 				}
 
 
 				slider.addEventListener( 'mousedown', slideReady );
 				slider.addEventListener( 'mousedown', slideReady );
-				window.addEventListener( 'mouseup', slideFinish );
 				slider.addEventListener( 'touchstart', slideReady );
 				slider.addEventListener( 'touchstart', slideReady );
-				window.addEventListener( 'touchstop', slideFinish );
+
+				window.addEventListener( 'mouseup', slideFinish );
+				window.addEventListener( 'touchend', slideFinish );
+
 				window.addEventListener( 'mousemove', slideMove );
 				window.addEventListener( 'mousemove', slideMove );
 				window.addEventListener( 'touchmove', slideMove );
 				window.addEventListener( 'touchmove', slideMove );