-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "refactor(components/transition): 调整transition组件",因为有两个元素时默认模式…
…不符合预期 This reverts commit feb33889decef2ffc5c60c78b7a77087a1822f42.
- Loading branch information
1 parent
09a250a
commit 1d42f23
Showing
5 changed files
with
40 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
import React, { memo } from 'react'; | ||
import { useDispatcher, useTransition } from './transition.hooks'; | ||
import { TransitionProps } from './transition.types'; | ||
import type { Mode, CB } from './transition.types'; | ||
|
||
export const Transition: React.FC<TransitionProps> = memo( | ||
({ | ||
const Transition: React.FC<{ | ||
// show?: boolean; | ||
name?: string; | ||
mode?: Mode; | ||
children?: React.ReactElement | boolean; | ||
appear?: boolean; | ||
on?: CB; | ||
}> = ({ | ||
children, | ||
name = 'trans', | ||
mode = 'default' /* , show */, | ||
appear = false, | ||
...props | ||
}): React.ReactElement => { | ||
const [prev, next, prevStatus, nextStatus, handler] = useDispatcher( | ||
mode, | ||
// show, | ||
appear, | ||
children, | ||
name = 'trans', | ||
mode = 'default' /* , show */, | ||
appear = false, | ||
...props | ||
}): React.ReactElement => { | ||
const [prev, next, prevStatus, nextStatus, handler] = useDispatcher( | ||
mode, | ||
// show, | ||
appear, | ||
children, | ||
props.on, | ||
); | ||
props.on, | ||
); | ||
|
||
// const prevView = useTransition('prev', prevStatus, name, prev, onAfterCb); | ||
// const nextView = useTransition('next', nextStatus, name, next, onAfterCb); | ||
const prevView = useTransition(prevStatus, name, prev, handler); | ||
const nextView = useTransition(nextStatus, name, next, handler); | ||
// const prevView = useTransition('prev', prevStatus, name, prev, onAfterCb); | ||
// const nextView = useTransition('next', nextStatus, name, next, onAfterCb); | ||
const prevView = useTransition(prevStatus, name, prev, handler); | ||
const nextView = useTransition(nextStatus, name, next, handler); | ||
|
||
if (prevView && !nextView) return prevView; | ||
if (!prevView && nextView) return nextView; | ||
if (prevView && !nextView) return prevView; | ||
if (!prevView && nextView) return nextView; | ||
|
||
return ( | ||
<> | ||
{prevView} | ||
{nextView} | ||
</> | ||
); | ||
}, | ||
); | ||
return ( | ||
<> | ||
{prevView} | ||
{nextView} | ||
</> | ||
); | ||
}; | ||
export default memo(Transition); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters