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 () {
|
||||
return {
|
||||
cellGroup: this
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleClick (name) {
|
||||
this.$emit('on-click', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -28,5 +28,5 @@
|
|||
default: ''
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -70,7 +70,7 @@
|
|||
data () {
|
||||
return {
|
||||
prefixCls: prefixCls
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
|
@ -89,5 +89,5 @@
|
|||
this.cellGroup.handleClick(this.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -50,8 +50,8 @@
|
|||
slotClasses() {
|
||||
return [
|
||||
`${prefixCls}-inner-text`,
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -7,13 +7,26 @@
|
|||
export default {
|
||||
name: 'Icon',
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
size: [Number, String],
|
||||
color: String
|
||||
color: String,
|
||||
custom: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return `${prefixCls} ${prefixCls}-${this.type}`;
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
{
|
||||
[`${prefixCls}-${this.type}`]: this.type !== '',
|
||||
[`${this.custom}`]: this.custom !== '',
|
||||
}
|
||||
];
|
||||
},
|
||||
styles () {
|
||||
let style = {};
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
import Split from './split.vue'
|
||||
export default Split
|
||||
import Split from './split.vue';
|
||||
export default Split;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
import { on, off } from '../../utils/dom';
|
||||
import Trigger from './trigger.vue'
|
||||
import Trigger from './trigger.vue';
|
||||
export default {
|
||||
name: 'Split',
|
||||
components: {
|
||||
|
@ -37,7 +37,7 @@ export default {
|
|||
},
|
||||
mode: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['horizontal', 'vertical'])
|
||||
return oneOf(value, ['horizontal', 'vertical']);
|
||||
},
|
||||
default: 'horizontal'
|
||||
},
|
||||
|
@ -62,94 +62,94 @@ export default {
|
|||
offset: 0,
|
||||
oldOffset: 0,
|
||||
isMoving: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
wrapperClasses () {
|
||||
return [
|
||||
`${this.prefix}-wrapper`,
|
||||
this.isMoving ? 'no-select' : ''
|
||||
]
|
||||
];
|
||||
},
|
||||
isHorizontal () {
|
||||
return this.mode === 'horizontal'
|
||||
return this.mode === 'horizontal';
|
||||
},
|
||||
anotherOffset () {
|
||||
return 100 - this.offset
|
||||
return 100 - this.offset;
|
||||
},
|
||||
valueIsPx () {
|
||||
return typeof this.value === 'string'
|
||||
return typeof this.value === 'string';
|
||||
},
|
||||
offsetSize () {
|
||||
return this.isHorizontal ? 'offsetWidth' : 'offsetHeight'
|
||||
return this.isHorizontal ? 'offsetWidth' : 'offsetHeight';
|
||||
},
|
||||
computedMin () {
|
||||
return this.getComputedThresholdValue('min')
|
||||
return this.getComputedThresholdValue('min');
|
||||
},
|
||||
computedMax () {
|
||||
return this.getComputedThresholdValue('max')
|
||||
return this.getComputedThresholdValue('max');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
px2percent (numerator, denominator) {
|
||||
return parseFloat(numerator) / parseFloat(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]
|
||||
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)
|
||||
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)
|
||||
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
|
||||
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)
|
||||
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')
|
||||
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')
|
||||
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
|
||||
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
|
||||
})
|
||||
}
|
||||
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -16,24 +16,24 @@ export default {
|
|||
return {
|
||||
prefix: 'ivu-split-trigger',
|
||||
initOffset: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isVertical () {
|
||||
return this.mode === 'vertical'
|
||||
return this.mode === 'vertical';
|
||||
},
|
||||
classes () {
|
||||
return [
|
||||
this.prefix,
|
||||
this.isVertical ? `${this.prefix}-vertical` : `${this.prefix}-horizontal`
|
||||
]
|
||||
];
|
||||
},
|
||||
barConClasses () {
|
||||
return [
|
||||
`${this.prefix}-bar-con`,
|
||||
this.isVertical ? 'vertical' : 'horizontal'
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -15,4 +15,4 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue