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 | 2 | import { animationOptions, animationValue2Name, firstLevelAnimationOptions } from '@/constants/animation.js' |
| 2 | -import 'animate.css' | |
| 3 | 3 | |
| 4 | 4 | export default { |
| 5 | + computed: { | |
| 6 | + ...mapState('editor', ['editingElement']) | |
| 7 | + }, | |
| 5 | 8 | data: () => ({ |
| 6 | 9 | animationQueue: [], |
| 7 | - activeCollapsePanel: [], | |
| 10 | + activeCollapsePanel: 0, | |
| 8 | 11 | activePreviewAnimation: '', |
| 9 | 12 | drawerVisible: false |
| 10 | 13 | }), |
| ... | ... | @@ -17,7 +20,7 @@ export default { |
| 17 | 20 | countNum: 1, |
| 18 | 21 | infinite: false |
| 19 | 22 | }) |
| 20 | - this.activeCollapsePanel = `${this.animationQueue.length - 1}` | |
| 23 | + this.activeCollapsePanel = this.animationQueue.length - 1 | |
| 21 | 24 | }, |
| 22 | 25 | deleteAnimate (index) { |
| 23 | 26 | this.animationQueue.splice(index, 1) |
| ... | ... | @@ -48,6 +51,10 @@ export default { |
| 48 | 51 | <a-list-item> |
| 49 | 52 | <div |
| 50 | 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 | 58 | onMouseenter={(e) => { |
| 52 | 59 | this.activePreviewAnimation = item.value |
| 53 | 60 | }} |
| ... | ... | @@ -117,6 +124,8 @@ export default { |
| 117 | 124 | } |
| 118 | 125 | }, |
| 119 | 126 | render (h) { |
| 127 | + const ele = this.editingElement | |
| 128 | + if (!ele) return (<span>请先选择一个元素</span>) | |
| 120 | 129 | return ( |
| 121 | 130 | <div class="main-animate widget" id="animation-edit-panel"> |
| 122 | 131 | <a-button-group> |
| ... | ... | @@ -125,13 +134,13 @@ export default { |
| 125 | 134 | </a-button-group> |
| 126 | 135 | { |
| 127 | 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 | 139 | this.animationQueue.map((addedAnimation, index) => ( |
| 131 | 140 | <a-collapse-panel key={`${index}`}> |
| 132 | 141 | <template slot="header"> |
| 133 | 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 | 144 | {/* <a-icon onClick={this.deleteAnimate(index)}></a-icon> */} |
| 136 | 145 | </template> |
| 137 | 146 | {this.renderAnimationOptions()} | ... | ... |