11/*! =======================================================
2- VERSION 10.6.0
2+ VERSION 10.6.1
33========================================================= */
44"use strict" ;
55
@@ -763,22 +763,10 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
763763 this . touchmove = this . _touchmove . bind ( this ) ;
764764
765765 if ( this . touchCapable ) {
766- // Test for passive event support
767- var supportsPassive = false ;
768- try {
769- var opts = Object . defineProperty ( { } , 'passive' , {
770- get : function get ( ) {
771- supportsPassive = true ;
772- }
773- } ) ;
774- window . addEventListener ( "test" , null , opts ) ;
775- } catch ( e ) { }
776- // Use our detect's results. passive applied if supported, capture will be false either way.
777- var eventOptions = supportsPassive ? { passive : true } : false ;
778- // Bind touch handlers
779- this . sliderElem . addEventListener ( "touchstart" , this . touchstart , eventOptions ) ;
780- this . sliderElem . addEventListener ( "touchmove" , this . touchmove , eventOptions ) ;
766+ this . sliderElem . addEventListener ( "touchstart" , this . touchstart , false ) ;
767+ this . sliderElem . addEventListener ( "touchmove" , this . touchmove , false ) ;
781768 }
769+
782770 this . sliderElem . addEventListener ( "mousedown" , this . mousedown , false ) ;
783771
784772 // Bind window handlers
@@ -816,13 +804,29 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
816804 } else {
817805 this . sliderElem . addEventListener ( "mouseenter" , this . showTooltip , false ) ;
818806 this . sliderElem . addEventListener ( "mouseleave" , this . hideTooltip , false ) ;
807+
808+ if ( this . touchCapable ) {
809+ this . sliderElem . addEventListener ( "touchstart" , this . showTooltip , false ) ;
810+ this . sliderElem . addEventListener ( "touchmove" , this . showTooltip , false ) ;
811+ this . sliderElem . addEventListener ( "touchend" , this . hideTooltip , false ) ;
812+ }
819813 }
820814
821815 this . handle1 . addEventListener ( "focus" , this . showTooltip , false ) ;
822816 this . handle1 . addEventListener ( "blur" , this . hideTooltip , false ) ;
823817
824818 this . handle2 . addEventListener ( "focus" , this . showTooltip , false ) ;
825819 this . handle2 . addEventListener ( "blur" , this . hideTooltip , false ) ;
820+
821+ if ( this . touchCapable ) {
822+ this . handle1 . addEventListener ( "touchstart" , this . showTooltip , false ) ;
823+ this . handle1 . addEventListener ( "touchmove" , this . showTooltip , false ) ;
824+ this . handle1 . addEventListener ( "touchend" , this . hideTooltip , false ) ;
825+
826+ this . handle2 . addEventListener ( "touchstart" , this . showTooltip , false ) ;
827+ this . handle2 . addEventListener ( "touchmove" , this . showTooltip , false ) ;
828+ this . handle2 . addEventListener ( "touchend" , this . hideTooltip , false ) ;
829+ }
826830 }
827831
828832 if ( this . options . enabled ) {
@@ -1076,9 +1080,9 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
10761080 - Place it underneath this comment block and write its signature like so:
10771081 _fnName : function() {...}
10781082 ********************************/
1079- _removeTooltipListener : function _removeTooltipListener ( event ) {
1080- this . handle1 . removeEventListener ( event , this . showTooltip , false ) ;
1081- this . handle2 . removeEventListener ( event , this . showTooltip , false ) ;
1083+ _removeTooltipListener : function _removeTooltipListener ( event , handler ) {
1084+ this . handle1 . removeEventListener ( event , handler , false ) ;
1085+ this . handle2 . removeEventListener ( event , handler , false ) ;
10821086 } ,
10831087 _removeSliderEventHandlers : function _removeSliderEventHandlers ( ) {
10841088 // Remove keydown event listeners
@@ -1104,10 +1108,10 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
11041108 this . ticksCallbackMap = null ;
11051109
11061110 if ( this . showTooltip ) {
1107- this . _removeTooltipListener ( "focus" ) ;
1111+ this . _removeTooltipListener ( "focus" , this . showTooltip ) ;
11081112 }
11091113 if ( this . hideTooltip ) {
1110- this . _removeTooltipListener ( "blur" ) ;
1114+ this . _removeTooltipListener ( "blur" , this . hideTooltip ) ;
11111115 }
11121116
11131117 // Remove event listeners from sliderElem
@@ -1117,10 +1121,35 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
11171121 if ( this . hideTooltip ) {
11181122 this . sliderElem . removeEventListener ( "mouseleave" , this . hideTooltip , false ) ;
11191123 }
1120- this . sliderElem . removeEventListener ( "touchstart" , this . touchstart , false ) ;
1121- this . sliderElem . removeEventListener ( "touchmove" , this . touchmove , false ) ;
1124+
11221125 this . sliderElem . removeEventListener ( "mousedown" , this . mousedown , false ) ;
11231126
1127+ if ( this . touchCapable ) {
1128+ // Remove touch event listeners from handles
1129+ if ( this . showTooltip ) {
1130+ this . handle1 . removeEventListener ( "touchstart" , this . showTooltip , false ) ;
1131+ this . handle1 . removeEventListener ( "touchmove" , this . showTooltip , false ) ;
1132+ this . handle2 . removeEventListener ( "touchstart" , this . showTooltip , false ) ;
1133+ this . handle2 . removeEventListener ( "touchmove" , this . showTooltip , false ) ;
1134+ }
1135+ if ( this . hideTooltip ) {
1136+ this . handle1 . removeEventListener ( "touchend" , this . hideTooltip , false ) ;
1137+ this . handle2 . removeEventListener ( "touchend" , this . hideTooltip , false ) ;
1138+ }
1139+
1140+ // Remove event listeners from sliderElem
1141+ if ( this . showTooltip ) {
1142+ this . sliderElem . removeEventListener ( "touchstart" , this . showTooltip , false ) ;
1143+ this . sliderElem . removeEventListener ( "touchmove" , this . showTooltip , false ) ;
1144+ }
1145+ if ( this . hideTooltip ) {
1146+ this . sliderElem . removeEventListener ( "touchend" , this . hideTooltip , false ) ;
1147+ }
1148+
1149+ this . sliderElem . removeEventListener ( "touchstart" , this . touchstart , false ) ;
1150+ this . sliderElem . removeEventListener ( "touchmove" , this . touchmove , false ) ;
1151+ }
1152+
11241153 // Remove window event listener
11251154 window . removeEventListener ( "resize" , this . resize , false ) ;
11261155 } ,
@@ -1562,14 +1591,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
15621591 return true ;
15631592 } ,
15641593 _touchstart : function _touchstart ( ev ) {
1565- if ( ev . changedTouches === undefined ) {
1566- this . _mousedown ( ev ) ;
1567- return ;
1568- }
1569-
1570- var touch = ev . changedTouches [ 0 ] ;
1571- this . touchX = touch . pageX ;
1572- this . touchY = touch . pageY ;
1594+ this . _mousedown ( ev ) ;
15731595 } ,
15741596 _triggerFocusOnHandle : function _triggerFocusOnHandle ( handleIdx ) {
15751597 if ( handleIdx === 0 ) {
@@ -1693,20 +1715,9 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
16931715 return ;
16941716 }
16951717
1696- var touch = ev . changedTouches [ 0 ] ;
1697-
1698- var xDiff = touch . pageX - this . touchX ;
1699- var yDiff = touch . pageY - this . touchY ;
1700-
1701- if ( ! this . _state . inDrag ) {
1702- // Vertical Slider
1703- if ( this . options . orientation === 'vertical' && xDiff <= 5 && xDiff >= - 5 && ( yDiff >= 15 || yDiff <= - 15 ) ) {
1704- this . _mousedown ( ev ) ;
1705- }
1706- // Horizontal slider.
1707- else if ( yDiff <= 5 && yDiff >= - 5 && ( xDiff >= 15 || xDiff <= - 15 ) ) {
1708- this . _mousedown ( ev ) ;
1709- }
1718+ // Prevent page from scrolling and only drag the slider
1719+ if ( ev . preventDefault ) {
1720+ ev . preventDefault ( ) ;
17101721 }
17111722 } ,
17121723 _adjustPercentageForRangeSliders : function _adjustPercentageForRangeSliders ( percentage ) {
@@ -1825,8 +1836,8 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
18251836 Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
18261837 */
18271838 _getPercentage : function _getPercentage ( ev ) {
1828- if ( this . touchCapable && ( ev . type === 'touchstart' || ev . type === 'touchmove' ) ) {
1829- ev = ev . touches [ 0 ] ;
1839+ if ( this . touchCapable && ( ev . type === 'touchstart' || ev . type === 'touchmove' || ev . type === 'touchend' ) ) {
1840+ ev = ev . changedTouches [ 0 ] ;
18301841 }
18311842
18321843 var eventPosition = ev [ this . mousePos ] ;
0 commit comments