Skip to content

Transition

Used to apply transition effects when elements enter or leave.

Component Types

Fade In/Out

Specify fade in/out related animations through name, suitable for prompts, floating layers, local content switching and other scenarios.

html
<wd-transition :show="show" name="fade">
  <view>Content</view>
</wd-transition>

Slide Animation

Built-in four slide directions: slide-up, slide-down, slide-left, slide-right.

html
<wd-transition :show="show" name="slide-up">
  <view>Content</view>
</wd-transition>

Zoom Animation

Built-in two zoom animations: zoom-in and zoom-out.

html
<wd-transition :show="show" name="zoom-in">
  <view>Content</view>
</wd-transition>

Special Styles

Custom Animation

Customize enter and leave animation class names through enter-class, enter-active-class, enter-to-class, leave-class, leave-active-class, leave-to-class.

duration supports numbers, and also supports configuring enter and leave durations separately, for example { enter: 700, leave: 1000 }.

html
<wd-transition
  :show="customShow"
  :duration="{ enter: 700, leave: 1000 }"
  enter-class="custom-enter"
  enter-active-class="custom-enter-active"
  enter-to-class="custom-enter-to"
  leave-class="custom-leave"
  leave-active-class="custom-leave-active"
  leave-to-class="custom-leave-to"
  custom-class="block"
/>
scss
:deep(.block) {
  position: fixed;
  left: 50%;
  top: 50%;
  margin: -50px 0 0 -50px;
  width: 100px;
  height: 100px;
  background: #0083ff;
}

:deep(.custom-enter-active),
:deep(.custom-leave-active) {
  transition-property: background, transform;
}

:deep(.custom-enter) {
  transform: translate3d(-100px, -100px, 0) rotate(-180deg);
  background: #ff0000;
}

:deep(.custom-leave-to) {
  transform: translate3d(100px, 100px, 0) rotate(180deg);
  background: #ff0000;
}

Attributes

ParameterDescriptionTypeDefault Value
showWhether to show componentbooleanfalse
durationAnimation execution time, supports uniform duration or setting enter and leave durations separatelynumber | boolean | Record<string, number>300
lazy-renderWhether to render content on first showbooleanfalse
nameAnimation type, optional values are fade, fade-up, fade-down, fade-left, fade-right, slide-up, slide-down, slide-left, slide-right, zoom-in, zoom-out, also supports array combining multiple animationsTransitionName | TransitionName[]-
destroyWhether to hide content via display: none after animation endsbooleantrue
enter-classEnter transition start state class namestring''
enter-active-classEnter transition active state class namestring''
enter-to-classEnter transition end state class namestring''
leave-classLeave transition start state class namestring''
leave-active-classLeave transition active state class namestring''
leave-to-classLeave transition end state class namestring''
disable-touch-move v1.11.0Whether to prevent touch scrollingbooleanfalse
custom-styleCustom root node stylestring''
custom-classCustom root node style classstring''

TransitionName Animation Types

NameDescription
fadeFade in/out
fade-downFade down
fade-leftFade left
fade-rightFade right
fade-upFade up
slide-downSlide down
slide-leftSlide left
slide-rightSlide right
slide-upSlide up
zoom-inZoom in
zoom-outZoom out

Events

Event NameDescriptionParameters
before-enterTriggered before enter-
enterTriggered when entering-
after-enterTriggered after enter-
before-leaveTriggered before leave-
leaveTriggered when leaving-
after-leaveTriggered after leave-
clickTriggered when clicking component-

Slots

NameDescription
defaultContent that needs animation effect

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.