parent
9c52988555
commit
7737645142
10 changed files with 467 additions and 156 deletions
File diff suppressed because one or more lines are too long
|
@ -9,12 +9,12 @@
|
||||||
provide () {
|
provide () {
|
||||||
return {
|
return {
|
||||||
cellGroup: this
|
cellGroup: this
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick (name) {
|
handleClick (name) {
|
||||||
this.$emit('on-click', name);
|
this.$emit('on-click', name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
|
@ -28,5 +28,5 @@
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
|
@ -70,7 +70,7 @@
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls
|
prefixCls: prefixCls
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
|
@ -89,5 +89,5 @@
|
||||||
this.cellGroup.handleClick(this.name);
|
this.cellGroup.handleClick(this.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
|
@ -50,8 +50,8 @@
|
||||||
slotClasses() {
|
slotClasses() {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-inner-text`,
|
`${prefixCls}-inner-text`,
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
|
@ -7,13 +7,26 @@
|
||||||
export default {
|
export default {
|
||||||
name: 'Icon',
|
name: 'Icon',
|
||||||
props: {
|
props: {
|
||||||
type: String,
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
size: [Number, String],
|
size: [Number, String],
|
||||||
color: String
|
color: String,
|
||||||
|
custom: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
return `${prefixCls} ${prefixCls}-${this.type}`;
|
return [
|
||||||
|
`${prefixCls}`,
|
||||||
|
{
|
||||||
|
[`${prefixCls}-${this.type}`]: this.type !== '',
|
||||||
|
[`${this.custom}`]: this.custom !== '',
|
||||||
|
}
|
||||||
|
];
|
||||||
},
|
},
|
||||||
styles () {
|
styles () {
|
||||||
let style = {};
|
let style = {};
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
import Split from './split.vue'
|
import Split from './split.vue';
|
||||||
export default Split
|
export default Split;
|
||||||
|
|
|
@ -24,132 +24,132 @@
|
||||||
<script>
|
<script>
|
||||||
import { oneOf } from '../../utils/assist';
|
import { oneOf } from '../../utils/assist';
|
||||||
import { on, off } from '../../utils/dom';
|
import { on, off } from '../../utils/dom';
|
||||||
import Trigger from './trigger.vue'
|
import Trigger from './trigger.vue';
|
||||||
export default {
|
export default {
|
||||||
name: 'Split',
|
name: 'Split',
|
||||||
components: {
|
components: {
|
||||||
Trigger
|
Trigger
|
||||||
},
|
|
||||||
props: {
|
|
||||||
value: {
|
|
||||||
type: [Number, String],
|
|
||||||
default: 0.5
|
|
||||||
},
|
},
|
||||||
mode: {
|
props: {
|
||||||
validator (value) {
|
value: {
|
||||||
return oneOf(value, ['horizontal', 'vertical'])
|
type: [Number, String],
|
||||||
},
|
default: 0.5
|
||||||
default: 'horizontal'
|
},
|
||||||
|
mode: {
|
||||||
|
validator (value) {
|
||||||
|
return oneOf(value, ['horizontal', 'vertical']);
|
||||||
|
},
|
||||||
|
default: 'horizontal'
|
||||||
|
},
|
||||||
|
min: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: '40px'
|
||||||
|
},
|
||||||
|
max: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: '40px'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
min: {
|
|
||||||
type: [Number, String],
|
|
||||||
default: '40px'
|
|
||||||
},
|
|
||||||
max: {
|
|
||||||
type: [Number, String],
|
|
||||||
default: '40px'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Events
|
* Events
|
||||||
* @on-move-start
|
* @on-move-start
|
||||||
* @on-moving 返回值:事件对象,但是在事件对象中加入了两个参数:atMin(当前是否在最小值处), atMax(当前是否在最大值处)
|
* @on-moving 返回值:事件对象,但是在事件对象中加入了两个参数:atMin(当前是否在最小值处), atMax(当前是否在最大值处)
|
||||||
* @on-move-end
|
* @on-move-end
|
||||||
*/
|
*/
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefix: 'ivu-split',
|
prefix: 'ivu-split',
|
||||||
offset: 0,
|
offset: 0,
|
||||||
oldOffset: 0,
|
oldOffset: 0,
|
||||||
isMoving: false
|
isMoving: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
wrapperClasses () {
|
||||||
|
return [
|
||||||
|
`${this.prefix}-wrapper`,
|
||||||
|
this.isMoving ? 'no-select' : ''
|
||||||
|
];
|
||||||
|
},
|
||||||
|
isHorizontal () {
|
||||||
|
return this.mode === 'horizontal';
|
||||||
|
},
|
||||||
|
anotherOffset () {
|
||||||
|
return 100 - this.offset;
|
||||||
|
},
|
||||||
|
valueIsPx () {
|
||||||
|
return typeof this.value === 'string';
|
||||||
|
},
|
||||||
|
offsetSize () {
|
||||||
|
return this.isHorizontal ? 'offsetWidth' : 'offsetHeight';
|
||||||
|
},
|
||||||
|
computedMin () {
|
||||||
|
return this.getComputedThresholdValue('min');
|
||||||
|
},
|
||||||
|
computedMax () {
|
||||||
|
return this.getComputedThresholdValue('max');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
px2percent (numerator, denominator) {
|
||||||
|
return parseFloat(numerator) / parseFloat(denominator);
|
||||||
|
},
|
||||||
|
getComputedThresholdValue (type) {
|
||||||
|
let size = this.$refs.outerWrapper[this.offsetSize];
|
||||||
|
if (this.valueIsPx) return typeof this[type] === 'string' ? this[type] : size * this[type];
|
||||||
|
else return typeof this[type] === 'string' ? this.px2percent(this[type], size) : this[type];
|
||||||
|
},
|
||||||
|
getMin (value1, value2) {
|
||||||
|
if (this.valueIsPx) return `${Math.min(parseFloat(value1), parseFloat(value2))}px`;
|
||||||
|
else return Math.min(value1, value2);
|
||||||
|
},
|
||||||
|
getMax (value1, value2) {
|
||||||
|
if (this.valueIsPx) return `${Math.max(parseFloat(value1), parseFloat(value2))}px`;
|
||||||
|
else return Math.max(value1, value2);
|
||||||
|
},
|
||||||
|
getAnotherOffset (value) {
|
||||||
|
let res = 0;
|
||||||
|
if (this.valueIsPx) res = `${this.$refs.outerWrapper[this.offsetSize] - parseFloat(value)}px`;
|
||||||
|
else res = 1 - value;
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
handleMove (e) {
|
||||||
|
let pageOffset = this.isHorizontal ? e.pageX : e.pageY;
|
||||||
|
let offset = pageOffset - this.initOffset;
|
||||||
|
let outerWidth = this.$refs.outerWrapper[this.offsetSize];
|
||||||
|
let value = this.valueIsPx ? `${parseFloat(this.oldOffset) + offset}px` : (this.px2percent(outerWidth * this.oldOffset + offset, outerWidth));
|
||||||
|
let anotherValue = this.getAnotherOffset(value);
|
||||||
|
if (parseFloat(value) <= parseFloat(this.computedMin)) value = this.getMax(value, this.computedMin);
|
||||||
|
if (parseFloat(anotherValue) <= parseFloat(this.computedMax)) value = this.getAnotherOffset(this.getMax(anotherValue, this.computedMax));
|
||||||
|
e.atMin = this.value === this.computedMin;
|
||||||
|
e.atMax = this.valueIsPx ? this.getAnotherOffset(this.value) === this.computedMax : this.getAnotherOffset(this.value).toFixed(5) === this.computedMax.toFixed(5);
|
||||||
|
this.$emit('input', value);
|
||||||
|
this.$emit('on-moving', e);
|
||||||
|
},
|
||||||
|
handleUp () {
|
||||||
|
this.isMoving = false;
|
||||||
|
off(document, 'mousemove', this.handleMove);
|
||||||
|
off(document, 'mouseup', this.handleUp);
|
||||||
|
this.$emit('on-move-end');
|
||||||
|
},
|
||||||
|
handleMousedown (e) {
|
||||||
|
this.initOffset = this.isHorizontal ? e.pageX : e.pageY;
|
||||||
|
this.oldOffset = this.value;
|
||||||
|
this.isMoving = true;
|
||||||
|
on(document, 'mousemove', this.handleMove);
|
||||||
|
on(document, 'mouseup', this.handleUp);
|
||||||
|
this.$emit('on-move-start');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
value () {
|
||||||
|
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
computed: {
|
|
||||||
wrapperClasses () {
|
|
||||||
return [
|
|
||||||
`${this.prefix}-wrapper`,
|
|
||||||
this.isMoving ? 'no-select' : ''
|
|
||||||
]
|
|
||||||
},
|
|
||||||
isHorizontal () {
|
|
||||||
return this.mode === 'horizontal'
|
|
||||||
},
|
|
||||||
anotherOffset () {
|
|
||||||
return 100 - this.offset
|
|
||||||
},
|
|
||||||
valueIsPx () {
|
|
||||||
return typeof this.value === 'string'
|
|
||||||
},
|
|
||||||
offsetSize () {
|
|
||||||
return this.isHorizontal ? 'offsetWidth' : 'offsetHeight'
|
|
||||||
},
|
|
||||||
computedMin () {
|
|
||||||
return this.getComputedThresholdValue('min')
|
|
||||||
},
|
|
||||||
computedMax () {
|
|
||||||
return this.getComputedThresholdValue('max')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
px2percent (numerator, denominator) {
|
|
||||||
return parseFloat(numerator) / parseFloat(denominator)
|
|
||||||
},
|
|
||||||
getComputedThresholdValue (type) {
|
|
||||||
let size = this.$refs.outerWrapper[this.offsetSize]
|
|
||||||
if (this.valueIsPx) return typeof this[type] === 'string' ? this[type] : size * this[type]
|
|
||||||
else return typeof this[type] === 'string' ? this.px2percent(this[type], size) : this[type]
|
|
||||||
},
|
|
||||||
getMin (value1, value2) {
|
|
||||||
if (this.valueIsPx) return `${Math.min(parseFloat(value1), parseFloat(value2))}px`
|
|
||||||
else return Math.min(value1, value2)
|
|
||||||
},
|
|
||||||
getMax (value1, value2) {
|
|
||||||
if (this.valueIsPx) return `${Math.max(parseFloat(value1), parseFloat(value2))}px`
|
|
||||||
else return Math.max(value1, value2)
|
|
||||||
},
|
|
||||||
getAnotherOffset (value) {
|
|
||||||
let res = 0
|
|
||||||
if (this.valueIsPx) res = `${this.$refs.outerWrapper[this.offsetSize] - parseFloat(value)}px`
|
|
||||||
else res = 1 - value
|
|
||||||
return res
|
|
||||||
},
|
|
||||||
handleMove (e) {
|
|
||||||
let pageOffset = this.isHorizontal ? e.pageX : e.pageY
|
|
||||||
let offset = pageOffset - this.initOffset
|
|
||||||
let outerWidth = this.$refs.outerWrapper[this.offsetSize]
|
|
||||||
let value = this.valueIsPx ? `${parseFloat(this.oldOffset) + offset}px` : (this.px2percent(outerWidth * this.oldOffset + offset, outerWidth))
|
|
||||||
let anotherValue = this.getAnotherOffset(value)
|
|
||||||
if (parseFloat(value) <= parseFloat(this.computedMin)) value = this.getMax(value, this.computedMin)
|
|
||||||
if (parseFloat(anotherValue) <= parseFloat(this.computedMax)) value = this.getAnotherOffset(this.getMax(anotherValue, this.computedMax))
|
|
||||||
e.atMin = this.value === this.computedMin
|
|
||||||
e.atMax = this.valueIsPx ? this.getAnotherOffset(this.value) === this.computedMax : this.getAnotherOffset(this.value).toFixed(5) === this.computedMax.toFixed(5)
|
|
||||||
this.$emit('input', value)
|
|
||||||
this.$emit('on-moving', e)
|
|
||||||
},
|
|
||||||
handleUp () {
|
|
||||||
this.isMoving = false
|
|
||||||
off(document, 'mousemove', this.handleMove)
|
|
||||||
off(document, 'mouseup', this.handleUp)
|
|
||||||
this.$emit('on-move-end')
|
|
||||||
},
|
|
||||||
handleMousedown (e) {
|
|
||||||
this.initOffset = this.isHorizontal ? e.pageX : e.pageY
|
|
||||||
this.oldOffset = this.value
|
|
||||||
this.isMoving = true
|
|
||||||
on(document, 'mousemove', this.handleMove)
|
|
||||||
on(document, 'mouseup', this.handleUp)
|
|
||||||
this.$emit('on-move-start')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
value () {
|
|
||||||
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -8,32 +8,32 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'Trigger',
|
name: 'Trigger',
|
||||||
props: {
|
props: {
|
||||||
mode: String
|
mode: String
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
prefix: 'ivu-split-trigger',
|
|
||||||
initOffset: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isVertical () {
|
|
||||||
return this.mode === 'vertical'
|
|
||||||
},
|
},
|
||||||
classes () {
|
data () {
|
||||||
return [
|
return {
|
||||||
this.prefix,
|
prefix: 'ivu-split-trigger',
|
||||||
this.isVertical ? `${this.prefix}-vertical` : `${this.prefix}-horizontal`
|
initOffset: 0
|
||||||
]
|
};
|
||||||
},
|
},
|
||||||
barConClasses () {
|
computed: {
|
||||||
return [
|
isVertical () {
|
||||||
`${this.prefix}-bar-con`,
|
return this.mode === 'vertical';
|
||||||
this.isVertical ? 'vertical' : 'horizontal'
|
},
|
||||||
]
|
classes () {
|
||||||
|
return [
|
||||||
|
this.prefix,
|
||||||
|
this.isVertical ? `${this.prefix}-vertical` : `${this.prefix}-horizontal`
|
||||||
|
];
|
||||||
|
},
|
||||||
|
barConClasses () {
|
||||||
|
return [
|
||||||
|
`${this.prefix}-bar-con`,
|
||||||
|
this.isVertical ? 'vertical' : 'horizontal'
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,4 +15,4 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
Loading…
Add table
Reference in a new issue