|
|
@@ -1,6 +1,6 @@
|
|
|
import {
|
|
|
- Transition as BaseTransition,
|
|
|
- TransitionProps,
|
|
|
+ BaseTransition,
|
|
|
+ BaseTransitionProps,
|
|
|
h,
|
|
|
warn,
|
|
|
FunctionalComponent,
|
|
|
@@ -13,7 +13,7 @@ import { ErrorCodes } from 'packages/runtime-core/src/errorHandling'
|
|
|
const TRANSITION = 'transition'
|
|
|
const ANIMATION = 'animation'
|
|
|
|
|
|
-export interface CSSTransitionProps extends TransitionProps {
|
|
|
+export interface TransitionProps extends BaseTransitionProps {
|
|
|
name?: string
|
|
|
type?: typeof TRANSITION | typeof ANIMATION
|
|
|
duration?: number | { enter: number; leave: number }
|
|
|
@@ -29,15 +29,15 @@ export interface CSSTransitionProps extends TransitionProps {
|
|
|
leaveToClass?: string
|
|
|
}
|
|
|
|
|
|
-// CSSTransition is a higher-order-component based on the platform-agnostic
|
|
|
+// DOM Transition is a higher-order-component based on the platform-agnostic
|
|
|
// base Transition component, with DOM-specific logic.
|
|
|
-export const CSSTransition: FunctionalComponent = (
|
|
|
- props: CSSTransitionProps,
|
|
|
+export const Transition: FunctionalComponent = (
|
|
|
+ props: TransitionProps,
|
|
|
{ slots }
|
|
|
-) => h(BaseTransition, resolveCSSTransitionProps(props), slots)
|
|
|
+) => h(BaseTransition, resolveTransitionProps(props), slots)
|
|
|
|
|
|
if (__DEV__) {
|
|
|
- CSSTransition.props = {
|
|
|
+ Transition.props = {
|
|
|
...(BaseTransition as any).props,
|
|
|
name: String,
|
|
|
type: String,
|
|
|
@@ -54,7 +54,7 @@ if (__DEV__) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function resolveCSSTransitionProps({
|
|
|
+function resolveTransitionProps({
|
|
|
name = 'v',
|
|
|
type,
|
|
|
duration,
|
|
|
@@ -68,7 +68,7 @@ function resolveCSSTransitionProps({
|
|
|
leaveActiveClass = `${name}-leave-active`,
|
|
|
leaveToClass = `${name}-leave-to`,
|
|
|
...baseProps
|
|
|
-}: CSSTransitionProps): TransitionProps {
|
|
|
+}: TransitionProps): BaseTransitionProps {
|
|
|
const instance = getCurrentInstance()!
|
|
|
const durations = normalizeDuration(duration)
|
|
|
const enterDuration = durations && durations[0]
|
|
|
@@ -147,7 +147,7 @@ function resolveCSSTransitionProps({
|
|
|
}
|
|
|
|
|
|
function normalizeDuration(
|
|
|
- duration: CSSTransitionProps['duration']
|
|
|
+ duration: TransitionProps['duration']
|
|
|
): [number, number] | null {
|
|
|
if (duration == null) {
|
|
|
return null
|
|
|
@@ -210,7 +210,7 @@ function nextFrame(cb: () => void) {
|
|
|
|
|
|
function whenTransitionEnds(
|
|
|
el: Element,
|
|
|
- expectedType: CSSTransitionProps['type'] | undefined,
|
|
|
+ expectedType: TransitionProps['type'] | undefined,
|
|
|
cb: () => void
|
|
|
) {
|
|
|
const { type, timeout, propCount } = getTransitionInfo(el, expectedType)
|
|
|
@@ -247,7 +247,7 @@ interface CSSTransitionInfo {
|
|
|
|
|
|
function getTransitionInfo(
|
|
|
el: Element,
|
|
|
- expectedType?: CSSTransitionProps['type']
|
|
|
+ expectedType?: TransitionProps['type']
|
|
|
): CSSTransitionInfo {
|
|
|
const styles: any = window.getComputedStyle(el)
|
|
|
// JSDOM may return undefined for transition properties
|