File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 433433 var end = { } ;
434434 var tracking = false ;
435435 var thresholdTime = 500 ;
436- var thresholdDistance = 75 ;
436+ var relativeScreenDistThreshold = 0.3 * ( mobileCheck ( ) ? 0.5 : 1 ) ;
437+ // 15-30% of the visible diagonal of the screen. should work seamlessly for any device/viewport, where mobile device swipes are more sensitive.
438+ var thresholdDistance = ( ( window . visualViewport ?. height ?? 1 ) ** 2 + ( window . visualViewport ?. width ?? 1 ) ** 2 ) ** 0.5 * relativeScreenDistThreshold ;
437439 gestureStart = function ( e ) {
438440 tracking = true ;
439441 /* Hack - would normally use e.timeStamp but it's whack in Fx/Android */
440442 start . t = new Date ( ) . getTime ( ) ;
441- start . x = e . clientX ;
442- start . y = e . clientY ;
443+ start . x = e . screenX ;
444+ start . y = e . screenY ;
443445 } ;
444446 gestureMove = function ( e ) {
445447 if ( tracking ) {
446448 e . preventDefault ( ) ;
447- end . x = e . clientX ;
448- end . y = e . clientY ;
449+ end . x = e . screenX ;
450+ end . y = e . screenY ;
449451 }
450452 }
451453 gestureEnd = function ( e ) {
474476 }
475477 }
476478 }
477- handle_gesture_left = function ( ) { write2log ( `Gesture fired: LEFT` , 1 ) ; audio_element . currentTime = 0 ; }
478- handle_gesture_right = function ( ) { write2log ( `Gesture fired: RIGHT` , 1 ) ; load_song_from_index ( ) ; }
479- handle_gesture_up = function ( ) { write2log ( `Gesture fired: UP` , 1 ) ; document . querySelector ( '#shuffle_button' ) . click ( ) ; }
480- handle_gesture_down = function ( ) { write2log ( `Gesture fired: DOWN` , 1 ) ; load_song_from_index ( ) ; }
479+ handle_gesture_left = function ( ) { write2log ( `Gesture fired: LEFT` , 1 ) ; document . querySelector ( 'audio' ) . currentTime = 0 ; }
480+ handle_gesture_right = function ( ) { write2log ( `Gesture fired: RIGHT` , 1 ) ; load_song_from_index ( ) ; }
481+ handle_gesture_up = function ( ) { write2log ( `Gesture fired: UP` , 1 ) ; document . querySelector ( '#shuffle_button' ) . click ( ) ; }
482+ handle_gesture_down = function ( ) { write2log ( `Gesture fired: DOWN` , 1 ) ; load_song_from_index ( ) ; }
481483
482484 args . forEach ( item => {
483485 item . step = item . step . toLowerCase ( ) ;
You can’t perform that action at this time.
0 commit comments