@@ -26,11 +26,9 @@ export default {
2626 }
2727 } ,
2828 mounted ( ) {
29- this . $nextTick ( ( ) => {
30- // mouseup won't trigger if mouse moved out of handle
31- // so we listen on document here.
32- this . onMouseUpListener = addEventListener ( document , 'mouseup' , this . handleMouseUp )
33- } )
29+ // mouseup won't trigger if mouse moved out of handle
30+ // so we listen on document here.
31+ this . onMouseUpListener = addEventListener ( document , 'mouseup' , this . handleMouseUp )
3432 } ,
3533 beforeDestroy ( ) {
3634 if ( this . onMouseUpListener ) {
@@ -46,8 +44,9 @@ export default {
4644 this . setClickFocus ( true )
4745 }
4846 } ,
49- handleBlur ( ) {
47+ handleBlur ( e ) {
5048 this . setClickFocus ( false )
49+ this . __emit ( 'blur' , e )
5150 } ,
5251 handleKeyDown ( ) {
5352 this . setClickFocus ( false )
@@ -62,12 +61,16 @@ export default {
6261 blur ( ) {
6362 this . $refs . handle . blur ( )
6463 } ,
64+ // when click can not focus in vue, use mousedown trigger focus
65+ handleMousedown ( e ) {
66+ this . focus ( )
67+ this . __emit ( 'mousedown' , e )
68+ } ,
6569 } ,
6670 render ( ) {
6771 const {
6872 prefixCls, vertical, offset, disabled, min, max, value, tabIndex,
6973 } = getOptionProps ( this )
70-
7174 const className = classNames (
7275 this . $props . className ,
7376 {
@@ -76,9 +79,7 @@ export default {
7679 )
7780
7881 const postionStyle = vertical ? { bottom : `${ offset } %` } : { left : `${ offset } %` }
79- const elStyle = {
80- ...postionStyle ,
81- }
82+
8283 const ariaProps = {
8384 'aria-valuemin' : min ,
8485 'aria-valuemax' : max ,
@@ -93,14 +94,17 @@ export default {
9394 ...ariaProps ,
9495 } ,
9596 class : className ,
96- on : this . $listeners ,
97+ on : {
98+ ...this . $listeners ,
99+ blur : this . handleBlur ,
100+ keydown : this . handleKeyDown ,
101+ mousedown : this . handleMousedown ,
102+ } ,
97103 ref : 'handle' ,
98- style : elStyle ,
104+ style : postionStyle ,
99105 }
100106 return (
101- < div
102- { ...handleProps }
103- />
107+ < div { ...handleProps } />
104108 )
105109 } ,
106110}
0 commit comments