@@ -7,7 +7,8 @@ export class Pin {
77
88 private keyListener : ( e : KeyboardEvent ) => void ;
99 private mouseDownListener : ( e : MouseEvent ) => void ;
10- private mouseUpListener : ( e : MouseEvent ) => void ;
10+ private touchStartListener : ( e : TouchEvent ) => void ;
11+ private mouseUpTouchEndListener : ( e : MouseEvent | TouchEvent ) => void ;
1112 private mouseLeaveListener : ( e : MouseEvent ) => void ;
1213
1314 constructor (
@@ -39,10 +40,12 @@ export class Pin {
3940
4041 this . mouseDownListener = ( e ) => {
4142 e . preventDefault ( ) ;
42- this . _mouseDown = true ;
43- this . press ( ) ;
43+ this . mouseDownTouchStartAction ( ) ;
4444 } ;
45- this . mouseUpListener = ( e ) => {
45+ this . touchStartListener = ( e ) => {
46+ this . mouseDownTouchStartAction ( ) ;
47+ } ;
48+ this . mouseUpTouchEndListener = ( e ) => {
4649 e . preventDefault ( ) ;
4750 if ( this . _mouseDown ) {
4851 this . _mouseDown = false ;
@@ -59,7 +62,9 @@ export class Pin {
5962 if ( this . ui ) {
6063 const { element } = this . ui ;
6164 element . addEventListener ( "mousedown" , this . mouseDownListener ) ;
62- element . addEventListener ( "mouseup" , this . mouseUpListener ) ;
65+ element . addEventListener ( "touchstart" , this . touchStartListener ) ;
66+ element . addEventListener ( "mouseup" , this . mouseUpTouchEndListener ) ;
67+ element . addEventListener ( "touchend" , this . mouseUpTouchEndListener ) ;
6368 element . addEventListener ( "keydown" , this . keyListener ) ;
6469 element . addEventListener ( "keyup" , this . keyListener ) ;
6570 element . addEventListener ( "mouseleave" , this . mouseLeaveListener ) ;
@@ -80,6 +85,11 @@ export class Pin {
8085 this . render ( ) ;
8186 }
8287
88+ private mouseDownTouchStartAction ( ) {
89+ this . _mouseDown = true ;
90+ this . press ( ) ;
91+ }
92+
8393 press ( ) {
8494 this . setValueInternal (
8595 this . state . value === this . state . min ? this . state . max : this . state . min ,
0 commit comments