Commit 911e0e61536d3878748d74678be2d945c86308e9
1 parent
28a72036
set default active animation tab
Showing
1 changed file
with
14 additions
and
5 deletions
front-end/h5/src/components/core/editor/edit-panel/animation.js
| 1 | +import { mapState } from 'vuex' | ||
| 1 | import { animationOptions, animationValue2Name, firstLevelAnimationOptions } from '@/constants/animation.js' | 2 | import { animationOptions, animationValue2Name, firstLevelAnimationOptions } from '@/constants/animation.js' |
| 2 | -import 'animate.css' | ||
| 3 | 3 | ||
| 4 | export default { | 4 | export default { |
| 5 | + computed: { | ||
| 6 | + ...mapState('editor', ['editingElement']) | ||
| 7 | + }, | ||
| 5 | data: () => ({ | 8 | data: () => ({ |
| 6 | animationQueue: [], | 9 | animationQueue: [], |
| 7 | - activeCollapsePanel: [], | 10 | + activeCollapsePanel: 0, |
| 8 | activePreviewAnimation: '', | 11 | activePreviewAnimation: '', |
| 9 | drawerVisible: false | 12 | drawerVisible: false |
| 10 | }), | 13 | }), |
| @@ -17,7 +20,7 @@ export default { | @@ -17,7 +20,7 @@ export default { | ||
| 17 | countNum: 1, | 20 | countNum: 1, |
| 18 | infinite: false | 21 | infinite: false |
| 19 | }) | 22 | }) |
| 20 | - this.activeCollapsePanel = `${this.animationQueue.length - 1}` | 23 | + this.activeCollapsePanel = this.animationQueue.length - 1 |
| 21 | }, | 24 | }, |
| 22 | deleteAnimate (index) { | 25 | deleteAnimate (index) { |
| 23 | this.animationQueue.splice(index, 1) | 26 | this.animationQueue.splice(index, 1) |
| @@ -48,6 +51,10 @@ export default { | @@ -48,6 +51,10 @@ export default { | ||
| 48 | <a-list-item> | 51 | <a-list-item> |
| 49 | <div | 52 | <div |
| 50 | class={[this.activePreviewAnimation === item.value && item.value + ' animated', 'shortcut-button']} | 53 | class={[this.activePreviewAnimation === item.value && item.value + ' animated', 'shortcut-button']} |
| 54 | + onClick={(e) => { | ||
| 55 | + // TODO move this to vuex mutation | ||
| 56 | + this.editingElement.animations[this.activeCollapsePanel].type = item.value | ||
| 57 | + }} | ||
| 51 | onMouseenter={(e) => { | 58 | onMouseenter={(e) => { |
| 52 | this.activePreviewAnimation = item.value | 59 | this.activePreviewAnimation = item.value |
| 53 | }} | 60 | }} |
| @@ -117,6 +124,8 @@ export default { | @@ -117,6 +124,8 @@ export default { | ||
| 117 | } | 124 | } |
| 118 | }, | 125 | }, |
| 119 | render (h) { | 126 | render (h) { |
| 127 | + const ele = this.editingElement | ||
| 128 | + if (!ele) return (<span>请先选择一个元素</span>) | ||
| 120 | return ( | 129 | return ( |
| 121 | <div class="main-animate widget" id="animation-edit-panel"> | 130 | <div class="main-animate widget" id="animation-edit-panel"> |
| 122 | <a-button-group> | 131 | <a-button-group> |
| @@ -125,13 +134,13 @@ export default { | @@ -125,13 +134,13 @@ export default { | ||
| 125 | </a-button-group> | 134 | </a-button-group> |
| 126 | { | 135 | { |
| 127 | this.animationQueue.length && | 136 | this.animationQueue.length && |
| 128 | - <a-collapse activeKey={this.activeCollapsePanel} onChange={(val) => { this.activeCollapsePanel = val }} class="collapse-wrapper"> | 137 | + <a-collapse activeKey={'' + this.activeCollapsePanel} onChange={(val) => { this.activeCollapsePanel = val }} class="collapse-wrapper"> |
| 129 | { | 138 | { |
| 130 | this.animationQueue.map((addedAnimation, index) => ( | 139 | this.animationQueue.map((addedAnimation, index) => ( |
| 131 | <a-collapse-panel key={`${index}`}> | 140 | <a-collapse-panel key={`${index}`}> |
| 132 | <template slot="header"> | 141 | <template slot="header"> |
| 133 | <span>动画{index + 1}</span> | 142 | <span>动画{index + 1}</span> |
| 134 | - <a-tag color="orange">{animationValue2Name[addedAnimation.type] }</a-tag> | 143 | + <a-tag color="orange">{animationValue2Name[addedAnimation.type] || addedAnimation.type }</a-tag> |
| 135 | {/* <a-icon onClick={this.deleteAnimate(index)}></a-icon> */} | 144 | {/* <a-icon onClick={this.deleteAnimate(index)}></a-icon> */} |
| 136 | </template> | 145 | </template> |
| 137 | {this.renderAnimationOptions()} | 146 | {this.renderAnimationOptions()} |