Merge pull request #6358 from msidolphin/fix/#6323

fix #6323
This commit is contained in:
debugIsFalse 2019-11-08 11:07:12 +08:00 committed by GitHub
commit cdf7c76054
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 90 deletions

View file

@ -69,7 +69,10 @@
prefix: 'ivu-split',
offset: 0,
oldOffset: 0,
isMoving: false
isMoving: false,
computedMin: 0,
computedMax: 0,
currentValue: 0.5
};
},
computed: {
@ -98,12 +101,6 @@
},
offsetSize () {
return this.isHorizontal ? 'offsetWidth' : 'offsetHeight';
},
computedMin () {
return this.getComputedThresholdValue('min');
},
computedMax () {
return this.getComputedThresholdValue('max');
}
},
methods: {
@ -157,22 +154,35 @@
this.$emit('on-move-start');
},
computeOffset(){
this.offset = (this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value) * 10000 / 100;
this.$nextTick(() => {
this.computedMin = this.getComputedThresholdValue('min');
this.computedMax = this.getComputedThresholdValue('max');
let value = this.valueIsPx ? this.px2percent(this.value, this.$refs.outerWrapper[this.offsetSize]) : this.value;
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));
this.offset = value * 10000 / 100;
this.currentValue = value;
this.$emit('input', value);
});
}
},
watch: {
value () {
this.computeOffset();
value (val) {
if (val !== this.currentValue) {
this.currentValue = val;
this.computeOffset();
}
}
},
mounted () {
this.$nextTick(() => {
this.computeOffset();
});
window.addEventListener('resize', ()=>{
this.computeOffset();
});
on(window, 'resize', this.computeOffset);
},
beforeDestroy () {
off(window, 'resize', this.computeOffset);
}
};
</script>