fix: 修复#6323

This commit is contained in:
msidolphin 2019-11-07 13:54:31 +08:00
parent e2ef9d91ea
commit c399c8fdbb
2 changed files with 41 additions and 90 deletions

View file

@ -1,90 +1,31 @@
<template>
<div>
<div class="demo-split">
<Split v-model="split1">
<div slot="left" class="demo-split-pane">
左边面板
</div>
<div slot="right" class="demo-split-pane">
右边面板
</div>
</Split>
</div>
<div class="demo-split">
<Split v-model="split1" mode="vertical">
<div slot="left" class="demo-split-pane">
左边面板
</div>
<div slot="right" class="demo-split-pane">
右边面板
</div>
</Split>
</div>
<div class="demo-split">
<Split v-model="split1" v-bind:min="min1">
<div slot="left" class="demo-split-pane">
Left Pane
</div>
<div slot="right" class="demo-split-pane">
Right Pane
</div>
</Split>
</div>
</template>
<script>
export default {
name: 'split_pane_page',
data () {
return {
offset: 0.6,
offsetVertical: '250px',
split1: 0.5
split1: 0.6,
min1: '400px'
}
},
methods: {
handleMoving (e) {
console.log(e.atMin, e.atMax)
}
}
}
</script>
<style lang="less">
.center-middle {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.split-pane-page-wrapper {
height: 600px;
.pane {
width: 100%;
height: 100%;
&.left-pane {
background: sandybrown;
}
&.right-pane {
background: palevioletred;
}
&.top-pane {
background: sandybrown;
}
&.bottom-pane {
background: palevioletred;
}
}
.custom-trigger {
width: 20px;
height: 20px;
border-radius: 50%;
background: #fff;
position: absolute;
.center-middle;
box-shadow: 0 0 6px 0 rgba(28, 36, 56, 0.4);
cursor: row-resize;
i.trigger-icon {
.center-middle;
}
}
}
</style>
<style>
.demo-split{
height: 300px;
border: 1px solid #dddee1;
height: 200px;
border: 1px solid #dcdee2;
}
</style>
.demo-split-pane{
padding: 10px;
}
</style>

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>