Skip to content

Commit 45f3bfc

Browse files
committed
feat: support resize the props panel; !#zh: 支持拖动调整右侧编辑面板
1 parent 6bc3011 commit 45f3bfc

File tree

5 files changed

+114
-41
lines changed

5 files changed

+114
-41
lines changed

front-end/h5/src/components/core/editor/canvas/edit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ export default {
294294
top: `${this.work.height}px`,
295295
width: '100%'
296296
}}>
297-
<div class="long-page-adjust">
298-
<div class="adjust-line"></div>
297+
<div class="adjust-line-wrapper adjust-line-wrapper-h">
298+
<div class="adjust-line adjust-line-h"></div>
299299
<div class="adjust-button" onMousedown={this.mousedownForAdjustLine}><div class="indicator"></div></div>
300300
<div class="adjust-tip">
301301
<span>320 x</span>

front-end/h5/src/components/core/editor/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import LogoOfHeader from '@/components/common/header/logo.js'
2020
import ExternalLinksOfHeader from '@/components/common/header/links.js'
2121
import LangSelect from '@/components/common/header/LangSelect.vue'
2222
import Feedback from '@/components/common/feedback/index'
23+
import AdjustLineV from '@/components/core/support/adjust-line/vertical'
2324

2425
// const sidebarMenus = [
2526
// {
@@ -113,7 +114,8 @@ export default {
113114
isPreviewMode: false,
114115
activeTabKey: '属性',
115116
previewVisible: false,
116-
scaleRate: 1
117+
scaleRate: 1,
118+
propsPanelWidth: 320
117119
}),
118120
computed: {
119121
...mapState('editor', {
@@ -349,6 +351,9 @@ export default {
349351
</div>
350352
</a-layout-content>
351353
</a-layout>
354+
<AdjustLineV onLineMove={(offset) => {
355+
this.propsPanelWidth += offset
356+
}} />
352357
<a-layout-sider width="40" theme='light' style={{ background: '#fff', border: '1px solid #eee' }}>
353358
{/* <div>
354359
<a-button shape="circle" icon="search" type="link" />
@@ -366,7 +371,7 @@ export default {
366371
}
367372
</a-button-group>
368373
</a-layout-sider>
369-
<a-layout-sider width="320" theme='light' style={{ background: '#fff', padding: '0 0 0 12px' }}>
374+
<a-layout-sider width={this.propsPanelWidth} data-set-width={this.propsPanelWidth} theme='light' style={{ background: '#fff', padding: '0 0 0 12px' }}>
370375
<a-tabs
371376
style="height: 100%;"
372377
tabBarGutter={10}

front-end/h5/src/components/core/styles/canvas-wrapper.scss

-37
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,3 @@ $designerWidthHalf: $designerWidth / 2;
3535
text-align: center;
3636
}
3737

38-
39-
.long-page-adjust {
40-
.adjust-line {
41-
width: 100%;
42-
height: 1px;
43-
background-color: #1593ff;
44-
}
45-
46-
.adjust-button {
47-
margin: 0 auto;
48-
width: 30px;
49-
height: 10px;
50-
border-radius: 2px;
51-
padding-top: 4px;
52-
cursor: ns-resize;
53-
background-color: #1593ff;
54-
55-
.indicator {
56-
margin: 0 auto;
57-
width: 10px;
58-
height: 1px;
59-
background-color: #ccd5db;
60-
}
61-
}
62-
63-
.adjust-tip {
64-
letter-spacing: 1px;
65-
padding: 0;
66-
height: 24px;
67-
margin: 2px auto 0;
68-
text-align: center;
69-
line-height: 24px;
70-
font-size: 12px;
71-
color: #868484;
72-
vertical-align: middle;
73-
}
74-
}

front-end/h5/src/components/core/styles/index.scss

+76
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,80 @@
9191
border-left: .2rem solid #dfe2e5;
9292
// margin: 1rem 0;
9393
padding: .25rem 0 .25rem 0.5rem;
94+
}
95+
96+
.ant-layout-sider {
97+
// 防止拖动延迟
98+
transition: none !important;
99+
}
100+
101+
$activeHoverColor: #1593ff;
102+
.adjust-line-wrapper {
103+
.adjust-line {
104+
border: 1px solid #eee;
105+
}
106+
107+
.adjust-line-h {
108+
width: 100%;
109+
}
110+
111+
.adjust-line-v {
112+
height: 100%;
113+
}
114+
115+
.adjust-button {
116+
display: flex;
117+
align-items: center;
118+
justify-content: center;
119+
margin: 0 auto;
120+
width: 30px;
121+
height: 10px;
122+
background-color: #fff;
123+
124+
.indicator {
125+
margin: 0 auto;
126+
width: 10px;
127+
height: 1px;
128+
background-color: #ccd5db;
129+
}
130+
}
131+
132+
&:hover {
133+
.adjust-button {
134+
background-color: $activeHoverColor;
135+
}
136+
137+
.adjust-line {
138+
border-color: $activeHoverColor;
139+
}
140+
}
141+
}
142+
143+
.adjust-line-wrapper-h {
144+
cursor: ns-resize;
145+
146+
.adjust-tip {
147+
letter-spacing: 1px;
148+
padding: 0;
149+
height: 24px;
150+
margin: 2px auto 0;
151+
text-align: center;
152+
line-height: 24px;
153+
font-size: 12px;
154+
color: #868484;
155+
vertical-align: middle;
156+
}
157+
}
158+
159+
.adjust-line-wrapper-v {
160+
position: relative;
161+
height: 100%;
162+
cursor: ew-resize;
163+
164+
.adjust-button {
165+
position: absolute;
166+
right: -10px;
167+
top: 50%;
168+
transform: rotate(90deg);
169+
}
94170
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export default {
2+
methods: {
3+
onMousedown (e) {
4+
let startX = e.clientX
5+
let move = moveEvent => {
6+
moveEvent.preventDefault()
7+
moveEvent.stopPropagation()
8+
const offset = startX - moveEvent.clientX
9+
this.$emit('lineMove', offset)
10+
startX -= offset
11+
}
12+
13+
let up = moveEvent => {
14+
document.removeEventListener('mousemove', move, true)
15+
document.removeEventListener('mouseup', up, true)
16+
}
17+
document.addEventListener('mousemove', move, true)
18+
document.addEventListener('mouseup', up, true)
19+
}
20+
},
21+
render () {
22+
return <div class="adjust-line-wrapper adjust-line-wrapper-v" onMousedown={this.onMousedown}>
23+
<div class="adjust-line adjust-line-v"></div>
24+
<div class="adjust-button">
25+
<div class="indicator"></div>
26+
</div>
27+
</div>
28+
}
29+
}

0 commit comments

Comments
 (0)