Skip to content

Transition Animation Component

This component is used for animation transition effects of components.

📌Platform Compatibility Notes

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯Basic Usage Example

html
<!-- Global usage -->
<hy-transition :show="show">
    <view class="transition">I am content</view>
</hy-transition>
ts
import { ref } from 'vue';

const show = ref(true);

Animation Modes

By setting mode

  • fade fade in
  • fade-up slide up and fade in
  • fade-down slide down and fade in
  • fade-left slide left and fade in
  • fade-right slide right and fade in
  • slide-up slide up in
  • slide-down slide down in
  • slide-left slide in from left
  • slide-right slide in from right
  • zoom-in zoom in
  • zoom-out zoom out
html
<template>
    <hy-transition :show="show" mode="zoom-in"></hy-transition>
</template>

Animation Transition

By setting timingFunction

  • linear: the transition effect runs at the same speed from start to end, equivalent to cubic-bezier(0,0,1,1).
  • ease: the transition effect starts slowly, then speeds up, and finally ends slowly. This is the default value, equivalent to cubic-bezier(0.25,0.1,0.25,1).
  • ease-in: the transition effect starts slowly and then gradually speeds up, equivalent to cubic-bezier(0.42,0,1,1).
  • ease-out: the transition effect starts quickly and then gradually slows down, equivalent to cubic-bezier(0,0,0.58,1).
  • ease-in-out: the transition effect starts slowly, speeds up in the middle, and then slows down at the end, equivalent to cubic-bezier(0.42,0,0.58,1).
html
<template>
    <hy-transition :show="show" timingFunction="linear"></hy-transition>
</template>

API

Transition Props

ParameterDescriptionTypeDefault
showWhether to show the componentbooleanfalse
modeAnimation mode to use, see above for detailsstringfade
durationDuration of the animation, in msnumber300
timingFunctionAnimation transition function, see abovestringease-out
customStyleDefine external styles to be usedCSSProperties-

Events

Event NameDescriptionCallback Parameters
beforeEnterTriggered before entering-
enterTriggered during entering-
afterEnterTriggered after entering-
beforeLeaveTriggered before leaving-
leaveTriggered during leaving-
afterLeaveTriggered after leaving-

Slots

Slot NameDescriptionAccepted Values
default--
03:29