feat: 添加强调动画

This commit is contained in:
pipipi-pikachu 2022-05-13 18:05:47 +08:00
parent c65a765fb3
commit 2da1bf6bf1
4 changed files with 56 additions and 7 deletions

View File

@ -183,3 +183,30 @@ export const EXIT_ANIMATIONS = [
], ],
}, },
] ]
export const ATTENTION_ANIMATIONS = [
{
type: 'shake',
name: '晃动',
children: [
{ name: '左右摇晃', value: 'shakeX' },
{ name: '上下摇晃', value: 'shakeY' },
{ name: '摇头', value: 'headShake' },
{ name: '摆动', value: 'swing' },
{ name: '晃动', value: 'wobble' },
{ name: '惊恐', value: 'tada' },
{ name: '果冻', value: 'jello' },
],
},
{
type: 'other',
name: '其他',
children: [
{ name: '弹跳', value: 'bounce' },
{ name: '闪烁', value: 'flash' },
{ name: '脉搏', value: 'pulse' },
{ name: '橡皮筋', value: 'rubberBand' },
{ name: '心跳(快)', value: 'heartBeat' },
],
},
]

View File

@ -574,7 +574,7 @@ export type PPTElement = PPTTextElement | PPTImageElement | PPTShapeElement | PP
* *
* effect: 动画效果 * effect: 动画效果
* *
* type: 退 * type: 退
* *
* duration: 动画持续时间 * duration: 动画持续时间
* *
@ -584,7 +584,7 @@ export interface PPTAnimation {
id: string; id: string;
elId: string; elId: string;
effect: string; effect: string;
type: 'in' | 'out'; type: 'in' | 'out' | 'attention';
duration: number; duration: number;
trigger: 'click' | 'meantime' | 'auto'; trigger: 'click' | 'meantime' | 'auto';
} }

View File

@ -31,7 +31,7 @@
class="animation-box" class="animation-box"
:class="[ :class="[
`${prefix}animated`, `${prefix}animated`,
`${prefix}faster`, `${prefix}fast`,
hoverPreviewAnimation === item.value && `${prefix}${item.value}`, hoverPreviewAnimation === item.value && `${prefix}${item.value}`,
]" ]"
>{{item.name}}</div> >{{item.name}}</div>
@ -122,6 +122,7 @@ import { PPTAnimation } from '@/types/slides'
import { import {
ENTER_ANIMATIONS, ENTER_ANIMATIONS,
EXIT_ANIMATIONS, EXIT_ANIMATIONS,
ATTENTION_ANIMATIONS,
ANIMATION_DEFAULT_DURATION, ANIMATION_DEFAULT_DURATION,
ANIMATION_DEFAULT_TRIGGER, ANIMATION_DEFAULT_TRIGGER,
ANIMATION_CLASS_PREFIX, ANIMATION_CLASS_PREFIX,
@ -142,8 +143,13 @@ for (const effect of EXIT_ANIMATIONS) {
animationEffects[animation.value] = animation.name animationEffects[animation.value] = animation.name
} }
} }
for (const effect of ATTENTION_ANIMATIONS) {
for (const animation of effect.children) {
animationEffects[animation.value] = animation.name
}
}
type AnimationType = 'in' | 'out' type AnimationType = 'in' | 'out' | 'attention'
interface TabItem { interface TabItem {
key: AnimationType; key: AnimationType;
label: string; label: string;
@ -162,6 +168,7 @@ export default defineComponent({
const tabs: TabItem[] = [ const tabs: TabItem[] = [
{ key: 'in', label: '入场' }, { key: 'in', label: '入场' },
{ key: 'out', label: '退场' }, { key: 'out', label: '退场' },
{ key: 'attention', label: '强调' },
] ]
const activeTab = ref('in') const activeTab = ref('in')
@ -303,11 +310,11 @@ export default defineComponent({
runAnimation(handleElementId.value, effect, ANIMATION_DEFAULT_DURATION) runAnimation(handleElementId.value, effect, ANIMATION_DEFAULT_DURATION)
} }
// 500ms // 600ms
const popoverMaskHide = ref(false) const popoverMaskHide = ref(false)
const handlePopoverVisibleChange = (visible: boolean) => { const handlePopoverVisibleChange = (visible: boolean) => {
if (visible) { if (visible) {
setTimeout(() => popoverMaskHide.value = true, 500) setTimeout(() => popoverMaskHide.value = true, 600)
} }
else popoverMaskHide.value = false else popoverMaskHide.value = false
} }
@ -331,6 +338,7 @@ export default defineComponent({
animations: { animations: {
in: ENTER_ANIMATIONS, in: ENTER_ANIMATIONS,
out: EXIT_ANIMATIONS, out: EXIT_ANIMATIONS,
attention: ATTENTION_ANIMATIONS,
}, },
prefix: ANIMATION_CLASS_PREFIX, prefix: ANIMATION_CLASS_PREFIX,
addAnimation, addAnimation,
@ -349,6 +357,7 @@ export default defineComponent({
<style lang="scss" scoped> <style lang="scss" scoped>
$inColor: #68a490; $inColor: #68a490;
$outColor: #d86344; $outColor: #d86344;
$attentionColor: #e8b76a;
.element-animation-panel { .element-animation-panel {
height: 100%; height: 100%;
@ -363,7 +372,7 @@ $outColor: #d86344;
margin-bottom: 20px; margin-bottom: 20px;
} }
.tab { .tab {
width: 50%; width: 33.33%;
padding-bottom: 8px; padding-bottom: 8px;
border-bottom: 2px solid transparent; border-bottom: 2px solid transparent;
text-align: center; text-align: center;
@ -378,6 +387,9 @@ $outColor: #d86344;
&.out.active { &.out.active {
border-bottom-color: $outColor; border-bottom-color: $outColor;
} }
&.attention.active {
border-bottom-color: $attentionColor;
}
} }
.element-animation { .element-animation {
height: 32px; height: 32px;
@ -423,6 +435,10 @@ $outColor: #d86344;
border-left-color: $outColor; border-left-color: $outColor;
background-color: rgba($color: $outColor, $alpha: .15); background-color: rgba($color: $outColor, $alpha: .15);
} }
&.attention .type-title {
border-left-color: $attentionColor;
background-color: rgba($color: $attentionColor, $alpha: .15);
}
} }
.type-title { .type-title {
width: 100%; width: 100%;
@ -468,6 +484,9 @@ $outColor: #d86344;
&.out.active { &.out.active {
border-color: $outColor; border-color: $outColor;
} }
&.attention.active {
border-color: $attentionColor;
}
&.active { &.active {
height: auto; height: auto;
} }

View File

@ -80,6 +80,9 @@ export default () => {
if (classname.indexOf(ANIMATION_CLASS_PREFIX) !== -1) elRef.classList.remove(classname, `${ANIMATION_CLASS_PREFIX}animated`) if (classname.indexOf(ANIMATION_CLASS_PREFIX) !== -1) elRef.classList.remove(classname, `${ANIMATION_CLASS_PREFIX}animated`)
} }
} }
// 如果撤销时该位置有且仅有强调动画,则继续执行一次撤销
if (animations.every(item => item.type === 'attention')) execPrev()
} }
// 关闭自动播放 // 关闭自动播放