State for Splitter
parent
ff72e63bf0
commit
8f0db108ce
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #383838;
|
background: #383838;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2908,7 +2908,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #3f4b5b;
|
background: #3f4b5b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #3f4b5b;
|
background: #3f4b5b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2908,7 +2908,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #3f4b5b;
|
background: #3f4b5b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #3f4b5b;
|
background: #3f4b5b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2908,7 +2908,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2908,7 +2908,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2871,7 +2871,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #edebe9;
|
background: #edebe9;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #edebe9;
|
background: #edebe9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #4b4b4b;
|
background: #4b4b4b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(255, 255, 255, 0.12);
|
background: rgba(255, 255, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2920,7 +2920,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: rgba(0, 0, 0, 0.12);
|
background: rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2871,7 +2871,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2883,7 +2883,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #d8dae2;
|
background: #d8dae2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2871,7 +2871,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dadada;
|
background: #dadada;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dadada;
|
background: #dadada;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #dee2e6;
|
background: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@
|
||||||
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
.p-splitter .p-splitter-gutter .p-splitter-gutter-handle {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
.p-splitter.p-splitter-resizing .p-splitter-gutter {
|
.p-splitter .p-splitter-gutter-resizing {
|
||||||
background: #304562;
|
background: #304562;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import Vue from 'vue';
|
||||||
declare class Splitter extends Vue {
|
declare class Splitter extends Vue {
|
||||||
layout?: string;
|
layout?: string;
|
||||||
gutterSize?: number;
|
gutterSize?: number;
|
||||||
|
stateKey?: string;
|
||||||
|
stateStorage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Splitter;
|
export default Splitter;
|
|
@ -2,7 +2,7 @@
|
||||||
<div :class="containerClass">
|
<div :class="containerClass">
|
||||||
<template v-for="(panel,i) of panels" :key="i" class="p-splitter-panel">
|
<template v-for="(panel,i) of panels" :key="i" class="p-splitter-panel">
|
||||||
<component :is="panel"></component>
|
<component :is="panel"></component>
|
||||||
<div ref="gutter" class="p-splitter-gutter" v-if="i !== (panels.length -1)" :style="gutterStyle" @mousedown="onGutterMouseDown($event)">
|
<div class="p-splitter-gutter" v-if="i !== (panels.length -1)" :style="gutterStyle" @mousedown="onGutterMouseDown($event, i)">
|
||||||
<div class="p-splitter-gutter-handle"></div>
|
<div class="p-splitter-gutter-handle"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
import DomHandler from '../utils/DomHandler';
|
import DomHandler from '../utils/DomHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
emits: ['resizeend'],
|
||||||
name: 'splitter',
|
name: 'splitter',
|
||||||
props: {
|
props: {
|
||||||
layout: {
|
layout: {
|
||||||
|
@ -22,19 +23,49 @@ export default {
|
||||||
gutterSize: {
|
gutterSize: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 4
|
default: 4
|
||||||
|
},
|
||||||
|
stateKey: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
stateStorage: {
|
||||||
|
type: String,
|
||||||
|
default: 'session'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dragging: false,
|
dragging: false,
|
||||||
mouseMoveListener: null,
|
mouseMoveListener: null,
|
||||||
mouseUpListener: null,
|
mouseUpListener: null,
|
||||||
size: null,
|
size: null,
|
||||||
|
gutterElement: null,
|
||||||
startPos: null,
|
startPos: null,
|
||||||
prevPanelElement: null,
|
prevPanelElement: null,
|
||||||
nextPanelElement: null,
|
nextPanelElement: null,
|
||||||
nextPanelSize: null,
|
nextPanelSize: null,
|
||||||
prevPanelSize: null,
|
prevPanelSize: null,
|
||||||
|
panelSizes: null,
|
||||||
|
prevPanelIndex: null,
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initialize();
|
if (this.panels && this.panels.length) {
|
||||||
|
let initialized = false;
|
||||||
|
if (this.isStateful()) {
|
||||||
|
initialized = this.restoreState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
let children = [...this.$el.children].filter(child => DomHandler.hasClass(child, 'p-splitter-panel'));
|
||||||
|
let _panelSizes = [];
|
||||||
|
|
||||||
|
this.panels.map((panel, i) => {
|
||||||
|
let panelInitialSize = panel.props && panel.props.size ? panel.props.size: null;
|
||||||
|
let panelSize = panelInitialSize || (100 / this.panels.length);
|
||||||
|
_panelSizes[i] = panelSize;
|
||||||
|
children[i].style.flexBasis = 'calc(' + panelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
||||||
|
});
|
||||||
|
|
||||||
|
this.panelSizes = _panelSizes;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
@ -44,28 +75,17 @@ export default {
|
||||||
isSplitterPanel(child) {
|
isSplitterPanel(child) {
|
||||||
return child.type.name === 'splitterpanel';
|
return child.type.name === 'splitterpanel';
|
||||||
},
|
},
|
||||||
initialize() {
|
onGutterMouseDown(event, index) {
|
||||||
if (this.panels && this.panels.length) {
|
this.gutterElement = event.currentTarget;
|
||||||
let children = [...this.$el.children].filter(child => DomHandler.hasClass(child, 'p-splitter-panel'));
|
|
||||||
|
|
||||||
this.panels.forEach((panel, i) => {
|
|
||||||
let panelSize = panel.props && panel.props.size ? panel.props.size: null;
|
|
||||||
|
|
||||||
if (panelSize)
|
|
||||||
children[i].style.flexBasis = 'calc(' + panelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
|
||||||
else
|
|
||||||
children[i].style.flexBasis = 'calc(' + (100 / this.panels.length) + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onGutterMouseDown(event) {
|
|
||||||
this.size = this.horizontal ? DomHandler.getWidth(this.$el) : DomHandler.getHeight(this.$el);
|
this.size = this.horizontal ? DomHandler.getWidth(this.$el) : DomHandler.getHeight(this.$el);
|
||||||
this.dragging = true;
|
this.dragging = true;
|
||||||
this.startPos = this.layout === 'horizontal' ? event.pageX : event.pageY;
|
this.startPos = this.layout === 'horizontal' ? event.pageX : event.pageY;
|
||||||
this.prevPanelElement = event.currentTarget.previousElementSibling;
|
this.prevPanelElement = this.gutterElement.previousElementSibling;
|
||||||
this.nextPanelElement = event.currentTarget.nextElementSibling;
|
this.nextPanelElement = this.gutterElement.nextElementSibling;
|
||||||
this.prevPanelSize = 100 * (this.horizontal ? DomHandler.getOuterWidth(this.prevPanelElement, true): DomHandler.getOuterHeight(this.prevPanelElement, true)) / this.size;
|
this.prevPanelSize = 100 * (this.horizontal ? DomHandler.getOuterWidth(this.prevPanelElement, true): DomHandler.getOuterHeight(this.prevPanelElement, true)) / this.size;
|
||||||
this.nextPanelSize = 100 * (this.horizontal ? DomHandler.getOuterWidth(this.nextPanelElement, true): DomHandler.getOuterHeight(this.nextPanelElement, true)) / this.size;
|
this.nextPanelSize = 100 * (this.horizontal ? DomHandler.getOuterWidth(this.nextPanelElement, true): DomHandler.getOuterHeight(this.nextPanelElement, true)) / this.size;
|
||||||
|
this.prevPanelIndex = index;
|
||||||
|
DomHandler.addClass(this.gutterElement, 'p-splitter-gutter-resizing');
|
||||||
DomHandler.addClass(this.$el, 'p-splitter-resizing');
|
DomHandler.addClass(this.$el, 'p-splitter-resizing');
|
||||||
this.bindListeners();
|
this.bindListeners();
|
||||||
},
|
},
|
||||||
|
@ -84,13 +104,22 @@ export default {
|
||||||
if (this.validateResize(newPrevPanelSize, newNextPanelSize)) {
|
if (this.validateResize(newPrevPanelSize, newNextPanelSize)) {
|
||||||
this.prevPanelElement.style.flexBasis = 'calc(' + newPrevPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
this.prevPanelElement.style.flexBasis = 'calc(' + newPrevPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
||||||
this.nextPanelElement.style.flexBasis = 'calc(' + newNextPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
this.nextPanelElement.style.flexBasis = 'calc(' + newNextPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
||||||
|
this.panelSizes[this.prevPanelIndex] = newPrevPanelSize;
|
||||||
|
this.panelSizes[this.prevPanelIndex + 1] = newNextPanelSize;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('mousemove', this.mouseMoveListener);
|
document.addEventListener('mousemove', this.mouseMoveListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.mouseUpListener) {
|
if (!this.mouseUpListener) {
|
||||||
this.mouseUpListener = () => {
|
this.mouseUpListener = (event) => {
|
||||||
|
if (this.isStateful()) {
|
||||||
|
this.saveState();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$emit('resizeend', {originalEvent: event, sizes: this.panelSizes});
|
||||||
|
DomHandler.removeClass(this.gutterElement, 'p-splitter-gutter-resizing');
|
||||||
|
DomHandler.removeClass(this.$el, 'p-splitter-resizing');
|
||||||
this.clear();
|
this.clear();
|
||||||
this.unbindListeners();
|
this.unbindListeners();
|
||||||
};
|
};
|
||||||
|
@ -127,7 +156,42 @@ export default {
|
||||||
this.nextPanelElement = null;
|
this.nextPanelElement = null;
|
||||||
this.prevPanelSize = null;
|
this.prevPanelSize = null;
|
||||||
this.nextPanelSize = null;
|
this.nextPanelSize = null;
|
||||||
DomHandler.removeClass(this.$el, 'p-splitter-resizing');
|
this.gutterElement = null;
|
||||||
|
this.prevPanelIndex = null;
|
||||||
|
},
|
||||||
|
isStateful() {
|
||||||
|
return this.stateKey != null;
|
||||||
|
},
|
||||||
|
getStorage() {
|
||||||
|
switch(this.stateStorage) {
|
||||||
|
case 'local':
|
||||||
|
return window.localStorage;
|
||||||
|
|
||||||
|
case 'session':
|
||||||
|
return window.sessionStorage;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(this.stateStorage + ' is not a valid value for the state storage, supported values are "local" and "session".');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveState() {
|
||||||
|
this.getStorage().setItem(this.stateKey, JSON.stringify(this.panelSizes));
|
||||||
|
},
|
||||||
|
restoreState() {
|
||||||
|
const storage = this.getStorage();
|
||||||
|
const stateString = storage.getItem(this.stateKey);
|
||||||
|
|
||||||
|
if (stateString) {
|
||||||
|
this.panelSizes = JSON.parse(stateString);
|
||||||
|
let children = [...this.$el.children].filter(child => DomHandler.hasClass(child, 'p-splitter-panel'));
|
||||||
|
children.forEach((child, i) => {
|
||||||
|
child.style.flexBasis = 'calc(' + this.panelSizes[i] + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -10,6 +10,15 @@
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Horizontal</h5>
|
<h5>Horizontal</h5>
|
||||||
|
<Splitter style="height: 300px" class="p-mb-5">
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 1
|
||||||
|
</SplitterPanel>
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 2
|
||||||
|
</SplitterPanel>
|
||||||
|
</Splitter>
|
||||||
|
|
||||||
<Splitter style="height: 300px">
|
<Splitter style="height: 300px">
|
||||||
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
Panel 1
|
Panel 1
|
||||||
|
@ -17,6 +26,9 @@
|
||||||
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
Panel 2
|
Panel 2
|
||||||
</SplitterPanel>
|
</SplitterPanel>
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 3
|
||||||
|
</SplitterPanel>
|
||||||
</Splitter>
|
</Splitter>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,23 @@ import SplitterPanel from 'primevue/splitterpanel';
|
||||||
</SplitterPanel>
|
</SplitterPanel>
|
||||||
</Splitter>
|
</Splitter>
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h5>Stateful</h5>
|
||||||
|
<p>Splitters can be configured as stateful so that when the user visits the page again, the adjusts sizes
|
||||||
|
can be restored. Define a <i>stateKey</i> to enable this feature. Default location of the state is
|
||||||
|
session storage and other option is the local storage which can be configured using the <i>stateStorage</i> property.</p>
|
||||||
|
<pre v-code>
|
||||||
|
<code>
|
||||||
|
<Splitter stateKey="mykey" stateStorage="local">
|
||||||
|
<SplitterPanel>
|
||||||
|
Panel 1
|
||||||
|
</SplitterPanel>
|
||||||
|
<SplitterPanel>
|
||||||
|
Panel 2
|
||||||
|
</SplitterPanel>
|
||||||
|
</Splitter>
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
<h5>Properties of SplitterPanel</h5>
|
<h5>Properties of SplitterPanel</h5>
|
||||||
|
@ -152,6 +169,18 @@ import SplitterPanel from 'primevue/splitterpanel';
|
||||||
<td>number</td>
|
<td>number</td>
|
||||||
<td>4</td>
|
<td>4</td>
|
||||||
<td>Size of the divider in pixels.</td>
|
<td>Size of the divider in pixels.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>stateKey</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Storage identifier of a stateful Splitter.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>stateStorage</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>session</td>
|
||||||
|
<td>Defines where a stateful splitter keeps its state, valid values are "session" for sessionStorage and "local" for localStorage.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -220,6 +249,18 @@ import SplitterPanel from 'primevue/splitterpanel';
|
||||||
Panel 2
|
Panel 2
|
||||||
</SplitterPanel>
|
</SplitterPanel>
|
||||||
</Splitter>
|
</Splitter>
|
||||||
|
|
||||||
|
<Splitter style="height: 300px">
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 1
|
||||||
|
</SplitterPanel>
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 2
|
||||||
|
</SplitterPanel>
|
||||||
|
<SplitterPanel class="p-d-flex p-ai-center p-jc-center">
|
||||||
|
Panel 3
|
||||||
|
</SplitterPanel>
|
||||||
|
</Splitter>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
Loading…
Reference in New Issue