|
@@ -4,27 +4,27 @@
|
|
<slot></slot>
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
- class="drag-bar"
|
|
|
|
- :class="[isColumn ? 'column' : 'horizontal', dragBarActive ? 'active' : '']"
|
|
|
|
- :style="dragBarStyleObj"
|
|
|
|
- @mousedown.prevent="handleDragBarMouseDown"
|
|
|
|
- ref="dragBarRef"
|
|
|
|
|
|
+ class="drag-bar"
|
|
|
|
+ :class="[isColumn ? 'column' : 'horizontal', dragBarActive ? 'active' : '']"
|
|
|
|
+ :style="dragBarStyleObj"
|
|
|
|
+ @mousedown.prevent="handleDragBarMouseDown"
|
|
|
|
+ ref="dragBarRef"
|
|
>
|
|
>
|
|
<div class="drag-bar-inner"></div>
|
|
<div class="drag-bar-inner"></div>
|
|
<div class="drag-handle" :style="dragHandleStyleObj">
|
|
<div class="drag-handle" :style="dragHandleStyleObj">
|
|
- <i class="dot"/>
|
|
|
|
- <i class="dot"/>
|
|
|
|
- <i class="dot"/>
|
|
|
|
|
|
+ <i class="dot" />
|
|
|
|
+ <i class="dot" />
|
|
|
|
+ <i class="dot" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</section>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
-import {defineComponent} from 'vue';
|
|
|
|
-import {Emitter} from 'mitt';
|
|
|
|
-import {debounce} from 'lodash';
|
|
|
|
-import {EmitterType} from '@/constants/emitter';
|
|
|
|
|
|
+import { defineComponent } from 'vue';
|
|
|
|
+import { Emitter } from 'mitt';
|
|
|
|
+import { debounce } from 'lodash';
|
|
|
|
+import { EmitterType } from '@/constants/emitter';
|
|
import ProvideInject from '@/constants/provideInject';
|
|
import ProvideInject from '@/constants/provideInject';
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
@@ -80,7 +80,7 @@ export default defineComponent({
|
|
const height = self.isColumn ? '5px' : '100%';
|
|
const height = self.isColumn ? '5px' : '100%';
|
|
const cursor = self.isColumn ? 'ns-resize' : 'ew-resize';
|
|
const cursor = self.isColumn ? 'ns-resize' : 'ew-resize';
|
|
const flexDirection = self.isColumn ? 'row' : 'column';
|
|
const flexDirection = self.isColumn ? 'row' : 'column';
|
|
- return {width, height, cursor, flexDirection};
|
|
|
|
|
|
+ return { width, height, cursor, flexDirection };
|
|
},
|
|
},
|
|
|
|
|
|
// 拖拽手柄的样式
|
|
// 拖拽手柄的样式
|
|
@@ -89,21 +89,21 @@ export default defineComponent({
|
|
const width = self.isColumn ? '36px' : '9px';
|
|
const width = self.isColumn ? '36px' : '9px';
|
|
const height = self.isColumn ? '9px' : '36px';
|
|
const height = self.isColumn ? '9px' : '36px';
|
|
const cursor = self.isColumn ? 'ns-resize' : 'ew-resize';
|
|
const cursor = self.isColumn ? 'ns-resize' : 'ew-resize';
|
|
- return {width, height, cursor};
|
|
|
|
|
|
+ return { width, height, cursor };
|
|
},
|
|
},
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
const self = this as any;
|
|
const self = this as any;
|
|
self.emitter = null;
|
|
self.emitter = null;
|
|
self.debouncedEmit = debounce(
|
|
self.debouncedEmit = debounce(
|
|
- () => {
|
|
|
|
- const size = this.isColumn
|
|
|
|
- ? (this.$refs.layoutItemRef as HTMLElement).offsetHeight
|
|
|
|
- : (this.$refs.layoutItemRef as HTMLElement).offsetWidth;
|
|
|
|
- this.$emit('resize', size);
|
|
|
|
- },
|
|
|
|
- self.debounce,
|
|
|
|
- {maxWait: self.maxWait}
|
|
|
|
|
|
+ () => {
|
|
|
|
+ const size = this.isColumn
|
|
|
|
+ ? (this.$refs.layoutItemRef as HTMLElement).offsetHeight
|
|
|
|
+ : (this.$refs.layoutItemRef as HTMLElement).offsetWidth;
|
|
|
|
+ this.$emit('resize', size);
|
|
|
|
+ },
|
|
|
|
+ self.debounce,
|
|
|
|
+ { maxWait: self.maxWait }
|
|
);
|
|
);
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -147,7 +147,7 @@ export default defineComponent({
|
|
instance: this,
|
|
instance: this,
|
|
index: this.getLayoutItemIndex(),
|
|
index: this.getLayoutItemIndex(),
|
|
minSize: (this as any)[this.minSize],
|
|
minSize: (this as any)[this.minSize],
|
|
- } as Comp.ResizableLayout.IDataParam);
|
|
|
|
|
|
+ } as ResizableLayout.IDataParam);
|
|
}
|
|
}
|
|
}, 500);
|
|
}, 500);
|
|
},
|
|
},
|
|
@@ -168,11 +168,11 @@ export default defineComponent({
|
|
// 向外触发 drag-bar-move
|
|
// 向外触发 drag-bar-move
|
|
emitMoveEvent(distance: number, moveId: symbol) {
|
|
emitMoveEvent(distance: number, moveId: symbol) {
|
|
(this as any).emitter &&
|
|
(this as any).emitter &&
|
|
- (this as any).emitter.emit(EmitterType.DRAG_BAR_MOVE, {
|
|
|
|
- index: this.getLayoutItemIndex(),
|
|
|
|
- distance,
|
|
|
|
- moveId,
|
|
|
|
- } as Comp.ResizableLayout.IMoveParam);
|
|
|
|
|
|
+ (this as any).emitter.emit(EmitterType.DRAG_BAR_MOVE, {
|
|
|
|
+ index: this.getLayoutItemIndex(),
|
|
|
|
+ distance,
|
|
|
|
+ moveId,
|
|
|
|
+ } as ResizableLayout.IMoveParam);
|
|
},
|
|
},
|
|
// 拖拽条移动
|
|
// 拖拽条移动
|
|
handleDragBarMouseDown(downEvent: MouseEvent) {
|
|
handleDragBarMouseDown(downEvent: MouseEvent) {
|