generated from react-component/footer
-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Prepare should always run (#42)
* chore: prepare note * chore: rm motion block code * feat: prepare always * test: add test case
- Loading branch information
Showing
7 changed files
with
145 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: provider | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/provider.tsx"></code> |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import classNames from 'classnames'; | ||
import CSSMotion, { Provider } from 'rc-motion'; | ||
import React from 'react'; | ||
import './basic.less'; | ||
|
||
export default () => { | ||
const [show, setShow] = React.useState(true); | ||
const [motion, setMotion] = React.useState(false); | ||
|
||
const onPrepare = (node: HTMLElement) => { | ||
console.log('🔥 prepare', node); | ||
|
||
return new Promise(resolve => { | ||
setTimeout(resolve, 500); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Provider motion={motion}> | ||
<button onClick={() => setShow(v => !v)}>show: {String(show)}</button> | ||
<button onClick={() => setMotion(v => !v)}> | ||
motion: {String(motion)} | ||
</button> | ||
|
||
<CSSMotion | ||
visible={show} | ||
motionName={'transition'} | ||
leavedClassName="hidden" | ||
motionAppear | ||
onAppearPrepare={onPrepare} | ||
onEnterPrepare={onPrepare} | ||
onLeavePrepare={onPrepare} | ||
onVisibleChanged={visible => { | ||
console.log('Visible Changed:', visible); | ||
}} | ||
> | ||
{({ style, className }, ref) => ( | ||
<> | ||
<div | ||
ref={ref} | ||
className={classNames('demo-block', className)} | ||
style={style} | ||
/> | ||
<ul> | ||
<li>ClassName: {JSON.stringify(className)}</li> | ||
<li>Style: {JSON.stringify(style)}</li> | ||
</ul> | ||
</> | ||
)} | ||
</CSSMotion> | ||
</Provider> | ||
); | ||
}; |
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
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
691ecfc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
motion – ./
motion-git-master-react-component.vercel.app
motion-seven.vercel.app
motion-react-component.vercel.app