@@ -672,21 +672,28 @@ export class MatSlider extends _MatSliderMixinBase
672
672
*/
673
673
private _bindGlobalEvents ( triggerEvent : TouchEvent | MouseEvent ) {
674
674
if ( typeof document !== 'undefined' && document ) {
675
+ const body = document . body ;
675
676
const isTouch = isTouchEvent ( triggerEvent ) ;
676
677
const moveEventName = isTouch ? 'touchmove' : 'mousemove' ;
677
678
const endEventName = isTouch ? 'touchend' : 'mouseup' ;
678
- document . body . addEventListener ( moveEventName , this . _pointerMove , activeEventOptions ) ;
679
- document . body . addEventListener ( endEventName , this . _pointerUp , activeEventOptions ) ;
679
+ body . addEventListener ( moveEventName , this . _pointerMove , activeEventOptions ) ;
680
+ body . addEventListener ( endEventName , this . _pointerUp , activeEventOptions ) ;
681
+
682
+ if ( isTouch ) {
683
+ body . addEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
684
+ }
680
685
}
681
686
}
682
687
683
688
/** Removes any global event listeners that we may have added. */
684
689
private _removeGlobalEvents ( ) {
685
690
if ( typeof document !== 'undefined' && document ) {
686
- document . body . removeEventListener ( 'mousemove' , this . _pointerMove , activeEventOptions ) ;
687
- document . body . removeEventListener ( 'mouseup' , this . _pointerUp , activeEventOptions ) ;
688
- document . body . removeEventListener ( 'touchmove' , this . _pointerMove , activeEventOptions ) ;
689
- document . body . removeEventListener ( 'touchend' , this . _pointerUp , activeEventOptions ) ;
691
+ const body = document . body ;
692
+ body . removeEventListener ( 'mousemove' , this . _pointerMove , activeEventOptions ) ;
693
+ body . removeEventListener ( 'mouseup' , this . _pointerUp , activeEventOptions ) ;
694
+ body . removeEventListener ( 'touchmove' , this . _pointerMove , activeEventOptions ) ;
695
+ body . removeEventListener ( 'touchend' , this . _pointerUp , activeEventOptions ) ;
696
+ body . removeEventListener ( 'touchcancel' , this . _pointerUp , activeEventOptions ) ;
690
697
}
691
698
}
692
699
0 commit comments