pull/165/head
wangxueliang 2018-03-26 12:18:06 +08:00
parent 6bf84b865c
commit 17ed8564f6
5 changed files with 24 additions and 14 deletions

View File

@ -13,12 +13,15 @@ export default {
},
render () {
const handle = (props) => {
const { value, dragging, index, ...restProps } = props
const { value, dragging, index, refStr, ...restProps } = props
const handleProps = {
props: {
...restProps,
value,
},
attrs: {
refStr,
},
key: index,
}
return (

View File

@ -53,10 +53,10 @@ export default {
this.focus()
},
focus () {
this.$refs[this.refStr].focus()
this.$refs.handle.focus()
},
blur () {
this.$refs[this.refStr].blur()
this.$refs.handle.blur()
},
},
render () {
@ -87,6 +87,7 @@ export default {
attrs: {
role: 'slider',
tabIndex: disabled ? null : (tabIndex || 0),
refStr,
...ariaProps,
...restProps,
},
@ -96,7 +97,7 @@ export default {
blur: this.handleBlur,
keydown: this.handleKeyDown,
},
ref: refStr,
ref: 'handle',
}
return (
<div

View File

@ -169,7 +169,6 @@ const Slider = {
const { sValue, dragging } = this
const offset = this.calcOffset(sValue)
const handle = handleGenerator({
className: `${prefixCls}-handle`,
prefixCls,
vertical,
offset,

View File

@ -42,12 +42,15 @@ export default function createSlider (Component) {
max: 100,
step: 1,
marks: {},
handle ({ index, ...restProps }) {
handle ({ index, refStr, ...restProps }) {
delete restProps.dragging
const handleProps = {
props: {
...restProps,
},
attrs: {
refStr,
},
key: index,
}
return <Handle {...handleProps} />
@ -90,10 +93,12 @@ export default function createSlider (Component) {
},
methods: {
setHandleRefs () {
const refs = this.$refs
Object.keys(refs).map((item) => {
if (item.indexOf('handlesRefs') > -1) {
const handleArr = item.split('handlesRefs')
const refs = this.$refs.handleRef
const children = Array.prototype.slice.call(refs.children)
children.map((item) => {
const refStr = item.getAttribute('refStr')
if (refStr.indexOf('handleRef') > -1) {
const handleArr = refStr.split('handleRef')
this.handlesRefs[handleArr[1]] = item
}
})
@ -305,7 +310,9 @@ export default function createSlider (Component) {
dotStyle={dotStyle}
activeDotStyle={activeDotStyle}
/>
{handles}
<div ref='handleRef'>
{handles}
</div>
<Marks
{...markProps}
/>

View File

@ -2,7 +2,7 @@
import PropTypes from '../_util/vue-types'
import Trigger from '../trigger'
import { placements } from './placements'
import { hasProp, getComponentFromProp } from '../_util/props-util'
import { hasProp, getComponentFromProp, getOptionProps } from '../_util/props-util'
function noop () {}
export default {
props: {
@ -57,14 +57,13 @@ export default {
destroyTooltipOnHide,
defaultVisible, getTooltipContainer,
...restProps
} = this.$props
} = getOptionProps(this)
const extraProps = { ...restProps }
if (hasProp(this, 'visible')) {
extraProps.popupVisible = this.$props.visible
}
const triggerProps = {
props: {
...extraProps,
popupClassName: overlayClassName,
prefixCls: prefixCls,
action: trigger,
@ -80,6 +79,7 @@ export default {
mouseLeaveDelay: mouseLeaveDelay,
popupStyle: overlayStyle,
mouseEnterDelay: mouseEnterDelay,
...extraProps,
},
on: {
popupVisibleChange: this.$listeners.visibleChange || noop,