Commit 9e04d09be121ea9a2db10a6c1cb92096553f99ee

Authored by ly525
1 parent 58d00484

feat(animation): support duration, delay, interation-count and infinite

front-end/h5/src/components/core/editor/edit-panel/animation.js
@@ -103,7 +103,7 @@ export default { @@ -103,7 +103,7 @@ export default {
103 </a-tabs> 103 </a-tabs>
104 ) 104 )
105 }, 105 },
106 - renderAnimationOptions () { 106 + renderAnimationOptions (animationOption) {
107 return ( 107 return (
108 <a-form layout="horizontal"> 108 <a-form layout="horizontal">
109 <a-form-item label="动画类型" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }}> 109 <a-form-item label="动画类型" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }}>
@@ -117,14 +117,86 @@ export default { @@ -117,14 +117,86 @@ export default {
117 </a-form-item> 117 </a-form-item>
118 <a-form-item label="动画时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;"> 118 <a-form-item label="动画时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
119 <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}> 119 <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
120 - <a-slider id="test" defaultValue={30} /> 120 + <a-slider
  121 + defaultValue={2}
  122 + min={0}
  123 + max={20}
  124 + value={animationOption.duration}
  125 + onChange={value => {
  126 + animationOption.duration = value
  127 + }}
  128 + />
121 </a-form-item> 129 </a-form-item>
  130 + <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)', marginLeft: '4px' }}>
  131 + <a-input-number
  132 + min={0}
  133 + max={20}
  134 + size="small"
  135 + formatter={value => `${value}秒`}
  136 + value={animationOption.duration}
  137 + onChange={value => {
  138 + animationOption.duration = value
  139 + }}
  140 + />
  141 + </a-form-item>
  142 + </a-form-item>
  143 + <a-form-item label="延迟时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
122 <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}> 144 <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
123 - <a-input-number min={1} max={20} size="small" formatter={value => `${value}秒`}/> 145 + <a-slider
  146 + defaultValue={2}
  147 + min={0}
  148 + max={20}
  149 + value={animationOption.delay}
  150 + onChange={value => {
  151 + animationOption.delay = value
  152 + }}
  153 + />
  154 + </a-form-item>
  155 + <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)', marginLeft: '4px' }}>
  156 + <a-input-number
  157 + min={0}
  158 + max={20}
  159 + size="small"
  160 + formatter={value => `${value}秒`}
  161 + value={animationOption.delay}
  162 + onChange={value => {
  163 + animationOption.delay = value
  164 + }}
  165 + />
  166 + </a-form-item>
  167 + </a-form-item>
  168 + <a-form-item label="运行次数" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
  169 + <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
  170 + <a-slider
  171 + defaultValue={2}
  172 + min={0}
  173 + max={20}
  174 + value={animationOption.interationCount}
  175 + onChange={value => {
  176 + animationOption.interationCount = value
  177 + }}
  178 + />
  179 + </a-form-item>
  180 + <a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)', marginLeft: '4px' }}>
  181 + <a-input-number
  182 + min={0}
  183 + max={20}
  184 + size="small"
  185 + formatter={value => `${value}次`}
  186 + value={animationOption.interationCount}
  187 + onChange={value => {
  188 + animationOption.interationCount = value
  189 + }}
  190 + />
124 </a-form-item> 191 </a-form-item>
125 </a-form-item> 192 </a-form-item>
126 <a-form-item label="循环播放" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;"> 193 <a-form-item label="循环播放" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
127 - <a-switch v-decorator="['switch', { valuePropName: 'checked' }]" /> 194 + <a-switch
  195 + value={animationOption.infinite}
  196 + onChange={value => {
  197 + animationOption.infinite = value
  198 + }}
  199 + />
128 </a-form-item> 200 </a-form-item>
129 </a-form> 201 </a-form>
130 ) 202 )
@@ -140,7 +212,9 @@ export default { @@ -140,7 +212,9 @@ export default {
140 <a-button type="primary" onClick={this.runAnimate}>运行动画<a-icon type="right-circle" /></a-button> 212 <a-button type="primary" onClick={this.runAnimate}>运行动画<a-icon type="right-circle" /></a-button>
141 </a-button-group> 213 </a-button-group>
142 { 214 {
143 - this.animationQueue.length && 215 + // Q:这边为何这样写:this.animationQueue.length && ?
  216 + // A:如果这样写的话,当 length === 0,的时候,0会显示在 UI 上
  217 + !!this.animationQueue.length &&
144 <a-collapse activeKey={'' + this.activeCollapsePanel} onChange={(val) => { this.activeCollapsePanel = val }} class="collapse-wrapper"> 218 <a-collapse activeKey={'' + this.activeCollapsePanel} onChange={(val) => { this.activeCollapsePanel = val }} class="collapse-wrapper">
145 { 219 {
146 this.animationQueue.map((addedAnimation, index) => ( 220 this.animationQueue.map((addedAnimation, index) => (
@@ -148,9 +222,9 @@ export default { @@ -148,9 +222,9 @@ export default {
148 <template slot="header"> 222 <template slot="header">
149 <span>动画{index + 1}</span> 223 <span>动画{index + 1}</span>
150 <a-tag color="orange">{animationValue2Name[addedAnimation.type] || addedAnimation.type }</a-tag> 224 <a-tag color="orange">{animationValue2Name[addedAnimation.type] || addedAnimation.type }</a-tag>
151 - {/* <a-icon onClick={this.deleteAnimate(index)}></a-icon> */} 225 + <a-icon type="delete" onClick={() => this.deleteAnimate(index)} title="删除动画"></a-icon>
152 </template> 226 </template>
153 - {this.renderAnimationOptions()} 227 + {this.renderAnimationOptions(addedAnimation)}
154 </a-collapse-panel> 228 </a-collapse-panel>
155 )) 229 ))
156 } 230 }