Skip to content

Commit 28a7203

Browse files
committed
feat: show avaiable animation list
1 parent 0208a79 commit 28a7203

File tree

6 files changed

+641
-23
lines changed

6 files changed

+641
-23
lines changed

front-end/h5/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"deploy": "rm -rf dist && npm run build && ./deploy.sh"
1212
},
1313
"dependencies": {
14+
"animate.css": "^3.7.2",
1415
"ant-design-vue": "^1.3.14",
1516
"core-js": "^2.6.5",
1617
"element-ui": "^2.9.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import { animationOptions, animationValue2Name, firstLevelAnimationOptions } from '@/constants/animation.js'
2+
import 'animate.css'
3+
4+
export default {
5+
data: () => ({
6+
animationQueue: [],
7+
activeCollapsePanel: [],
8+
activePreviewAnimation: '',
9+
drawerVisible: false
10+
}),
11+
methods: {
12+
addAnimation () {
13+
this.animationQueue.push({
14+
type: '',
15+
duration: 0,
16+
delay: 0,
17+
countNum: 1,
18+
infinite: false
19+
})
20+
this.activeCollapsePanel = `${this.animationQueue.length - 1}`
21+
},
22+
deleteAnimate (index) {
23+
this.animationQueue.splice(index, 1)
24+
},
25+
runAnimate () {
26+
},
27+
renderSecondAnimationTabs (animations) {
28+
return (
29+
<a-tabs
30+
defaultActiveKey={animations[0].value}
31+
onChange={tab => {}}
32+
style="width:100%;"
33+
tabBarStyle={{ marginLeft: '-16px' }}
34+
size="small"
35+
tabBarGutter={0}
36+
tabPosition="left"
37+
>
38+
{
39+
animations.map(group => (
40+
<a-tab-pane tab={group.label || group.value} key={group.value}>
41+
<a-list
42+
grid={{ gutter: 12, column: 2 }}
43+
dataSource={group.children}
44+
renderItem={(item, index) => (
45+
// [key point] onMouseover vs onMouseenter
46+
// https://stackoverflow.com/questions/7286532/jquery-mouseenter-vs-mouseover
47+
// https://www.quirksmode.org/js/events_mouse.html#mouseenter
48+
<a-list-item>
49+
<div
50+
class={[this.activePreviewAnimation === item.value && item.value + ' animated', 'shortcut-button']}
51+
onMouseenter={(e) => {
52+
this.activePreviewAnimation = item.value
53+
}}
54+
onMouseleave={() => {
55+
// [key point] why not set activePreviewAnimation='' after mouseleave, see more here: https://stackoverflow.com/questions/32279782/mouseenter-called-multiple-times
56+
// this.activePreviewAnimation = ''
57+
}}
58+
>
59+
{item.label}
60+
</div>
61+
</a-list-item>
62+
)}
63+
>
64+
</a-list>
65+
</a-tab-pane>
66+
))
67+
}
68+
</a-tabs>
69+
)
70+
},
71+
renderAvaiableAnimations () {
72+
return (
73+
<a-tabs
74+
defaultActiveKey={firstLevelAnimationOptions[0].label}
75+
onChange={tab => {}}
76+
style="width:100%;"
77+
tabBarStyle={{}}
78+
size="small"
79+
tabBarGutter={0}
80+
>
81+
{
82+
firstLevelAnimationOptions.map(firstGroup => (
83+
<a-tab-pane tab={firstGroup.label} key={firstGroup.label}>
84+
{/* group.label.match(firstGroup.value) <-> !!'abc'.match(/a|e/) === true */}
85+
{this.renderSecondAnimationTabs(animationOptions.filter(group => !!group.label.match(firstGroup.value)))}
86+
</a-tab-pane>
87+
))
88+
}
89+
</a-tabs>
90+
)
91+
},
92+
renderAnimationOptions () {
93+
return (
94+
<a-form layout="horizontal">
95+
<a-form-item label="动画类型" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }}>
96+
{/* <a-popover placement="left" title="动画列表" trigger="click">
97+
<template slot="content">
98+
{this.renderAvaiableAnimations()}
99+
</template>
100+
<a-button type="primary">动画列表</a-button>
101+
</a-popover> */}
102+
<a-button type="link" size="small" icon="ordered-list" onClick={() => { this.drawerVisible = true }}>动画列表</a-button>
103+
</a-form-item>
104+
<a-form-item label="动画时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
105+
<a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
106+
<a-slider id="test" defaultValue={30} />
107+
</a-form-item>
108+
<a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
109+
<a-input-number min={1} max={20} size="small" formatter={value => `${value}秒`}/>
110+
</a-form-item>
111+
</a-form-item>
112+
<a-form-item label="循环播放" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
113+
<a-switch v-decorator="['switch', { valuePropName: 'checked' }]" />
114+
</a-form-item>
115+
</a-form>
116+
)
117+
}
118+
},
119+
render (h) {
120+
return (
121+
<div class="main-animate widget" id="animation-edit-panel">
122+
<a-button-group>
123+
<a-button type="primary" onClick={this.addAnimation}><a-icon type="plus" />添加动画</a-button>
124+
<a-button type="primary" onClick={this.runAnimate}>运行动画<a-icon type="right-circle" /></a-button>
125+
</a-button-group>
126+
{
127+
this.animationQueue.length &&
128+
<a-collapse activeKey={this.activeCollapsePanel} onChange={(val) => { this.activeCollapsePanel = val }} class="collapse-wrapper">
129+
{
130+
this.animationQueue.map((addedAnimation, index) => (
131+
<a-collapse-panel key={`${index}`}>
132+
<template slot="header">
133+
<span>动画{index + 1}</span>
134+
<a-tag color="orange">{animationValue2Name[addedAnimation.type] }</a-tag>
135+
{/* <a-icon onClick={this.deleteAnimate(index)}></a-icon> */}
136+
</template>
137+
{this.renderAnimationOptions()}
138+
</a-collapse-panel>
139+
))
140+
}
141+
</a-collapse>
142+
}
143+
144+
<a-drawer
145+
title="请选择动画"
146+
placement="left"
147+
closable={true}
148+
onClose={() => { this.drawerVisible = false }}
149+
visible={this.drawerVisible}
150+
width={400}
151+
wrapStyle={{ margin: '-16px' }}
152+
>
153+
<div style="width: 100%;">
154+
{this.renderAvaiableAnimations()}
155+
</div>
156+
</a-drawer>
157+
</div>
158+
)
159+
}
160+
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import RenderEditCanvas from './canvas/edit'
88
import RenderPreviewCanvas from './canvas/preview'
99
import RenderPropsEditor from './edit-panel/props'
1010
import RenderScriptEditor from './edit-panel/script'
11+
import RenderAnimationEditor from './edit-panel/animation'
1112
import RenderActoionEditor from './edit-panel/action'
1213
import RenderShortcutsPanel from './shortcuts-panel/index'
1314
import PreviewDialog from './modals/preview.vue'
@@ -281,7 +282,7 @@ export default {
281282
{/* { this.renderPropsEditorPanel(h) } */}
282283
<RenderPropsEditor/>
283284
</a-tab-pane>
284-
<a-tab-pane label="动画" key='动画' tab='动画'>动画</a-tab-pane>
285+
<a-tab-pane label="动画" key='动画' tab='动画'><RenderAnimationEditor /></a-tab-pane>
285286
<a-tab-pane label="动作" key='动作' tab='动作'>{this.activeTabKey === '动作'}{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane>
286287
<a-tab-pane label="脚本" key='脚本' tab='脚本'><RenderScriptEditor/></a-tab-pane>
287288
</a-tabs>

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

+45-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
@mixin shortcut-button {
2+
border: 1px dashed #fff;
3+
height: 60px;
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
7+
cursor: pointer;
8+
transition: all .25s;
9+
background-color: #f5f8fb;
10+
margin-bottom: 15px;
11+
flex-direction: column;
12+
color: #393e46;
13+
width: 100%;
14+
15+
&:disabled {
16+
cursor: not-allowed;
17+
}
18+
.shortcut-icon {
19+
padding: 4px;
20+
// display: block;
21+
// font-size: 16px;
22+
// margin-bottom: 10px;
23+
}
24+
}
25+
126
#luban-editor-layout,
227
#luban-work-manager-layout {
328
.header {
@@ -29,30 +54,10 @@
2954
}
3055

3156
.shortcut-button {
32-
border: 1px dashed #fff;
33-
height: 60px;
34-
display: flex;
35-
align-items: center;
36-
justify-content: center;
37-
cursor: pointer;
38-
transition: all .25s;
39-
background-color: #f5f8fb;
40-
margin-bottom: 15px;
41-
flex-direction: column;
42-
color: #393e46;
43-
width: 100%;
44-
45-
&:disabled {
46-
cursor: not-allowed;
47-
}
48-
.shortcut-icon {
49-
padding: 4px;
50-
// display: block;
51-
// font-size: 16px;
52-
// margin-bottom: 10px;
53-
}
57+
@include shortcut-button;
5458
}
5559

60+
5661
.canvas-wrapper {
5762
border: 1px dashed #e7e7e7;
5863
// padding: '12px';
@@ -122,7 +127,25 @@
122127
background-repeat: no-repeat;
123128
background-position: center center;
124129
}
130+
}
131+
132+
.shortcut-button {
133+
@include shortcut-button;
134+
}
135+
136+
// 动画编辑面板定制
137+
#animation-edit-panel {
138+
.ant-collapse-header {
139+
padding: 6px 0 6px 40px;
140+
}
141+
142+
.collapse-wrapper {
143+
margin-top: 12px;
125144

145+
.ant-form-item {
146+
margin-bottom: 0;
147+
}
148+
}
126149
}
127150

128151
.default-router-link {

0 commit comments

Comments
 (0)