@@ -45,18 +45,16 @@ export default function createSlider (Component) {
4545 max : 100 ,
4646 step : 1 ,
4747 marks : { } ,
48- handle ( h , { index, refStr , className, style, ...restProps } ) {
48+ handle ( h , { index, ref , className, style, ...restProps } ) {
4949 delete restProps . dragging
5050 const handleProps = {
5151 props : {
5252 ...restProps ,
5353 } ,
54- attrs : {
55- refStr,
56- } ,
5754 class : className ,
5855 style,
5956 key : index ,
57+ ref,
6058 }
6159 return < Handle { ...handleProps } />
6260 } ,
@@ -80,7 +78,6 @@ export default function createSlider (Component) {
8078 step
8179 )
8280 }
83- this . handlesRefs = [ ]
8481 return { }
8582 } ,
8683 beforeDestroy ( ) {
@@ -93,21 +90,22 @@ export default function createSlider (Component) {
9390 this . $nextTick ( ( ) => {
9491 // Snapshot testing cannot handle refs, so be sure to null-check this.
9592 this . document = this . $refs . sliderRef && this . $refs . sliderRef . ownerDocument
96- this . setHandleRefs ( )
93+ // this.setHandleRefs()
9794 } )
9895 } ,
99- methods : {
100- setHandleRefs ( ) {
101- const refs = this . $refs . handleRef
102- const children = Array . prototype . slice . call ( refs . children )
103- children . map ( ( item ) => {
104- const refStr = item . getAttribute ( 'refStr' )
105- if ( refStr . indexOf ( 'handleRef' ) > - 1 ) {
106- const handleArr = refStr . split ( 'handleRef' )
107- this . handlesRefs [ handleArr [ 1 ] ] = item
96+ computed : {
97+ handlesRefs ( ) {
98+ const handlesRefs = [ ]
99+ for ( const [ k , v ] of Object . entries ( this . $refs ) ) {
100+ const matchs = k . match ( / h a n d l e R e f s _ ( \d + $ ) / )
101+ if ( matchs ) {
102+ handlesRefs [ + matchs [ 1 ] ] = v
108103 }
109- } )
104+ }
105+ return handlesRefs
110106 } ,
107+ } ,
108+ methods : {
111109 onMouseDown ( e ) {
112110 if ( e . button !== 0 ) { return }
113111 const isVertical = this . vertical
@@ -172,11 +170,16 @@ export default function createSlider (Component) {
172170 /* eslint-enable no-unused-expressions */
173171 } ,
174172 onMouseUp ( ) {
175- if ( this . $children && this . $children [ this . prevMovedHandleIndex ] ) {
176- const handleCom = utils . getComponentProps ( this . $children [ this . prevMovedHandleIndex ] , 'clickFocus' )
177- if ( handleCom ) {
178- handleCom . clickFocus ( )
179- }
173+ // if (this.$children && this.$children[this.prevMovedHandleIndex]) {
174+ // const handleCom = utils.getComponentProps(this.$children[this.prevMovedHandleIndex], 'clickFocus')
175+ // console.log('handleCom', handleCom)
176+ // if (handleCom) {
177+ // // handleCom.clickFocus()
178+ // }
179+
180+ // }
181+ if ( this . handlesRefs [ this . prevMovedHandleIndex ] ) {
182+ this . handlesRefs [ this . prevMovedHandleIndex ] . clickFocus ( )
180183 }
181184 } ,
182185 onMouseMove ( e ) {
@@ -244,7 +247,8 @@ export default function createSlider (Component) {
244247 } ,
245248 onClickMarkLabel ( e , value ) {
246249 e . stopPropagation ( )
247- this . $emit ( 'change' , { value } )
250+ this . onChange ( { value } )
251+ // this.$emit('change', value)
248252 } ,
249253 } ,
250254 render ( h ) {
@@ -318,9 +322,7 @@ export default function createSlider (Component) {
318322 dotStyle = { dotStyle }
319323 activeDotStyle = { activeDotStyle }
320324 />
321- < div ref = 'handleRef' >
322- { handles }
323- </ div >
325+ { handles }
324326 < Marks
325327 { ...markProps }
326328 />
0 commit comments