Skip to content

Commit

Permalink
feat: add fading exits animations
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Jun 26, 2020
1 parent 7badc87 commit 6eec3e6
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,22 @@ const { ref } = useWebAnimations({
- fadeInTopRight
- fadeInBottomLeft
- fadeInBottomRight

#### Fading exits

- fadeOut
- fadeOutDown
- fadeOutDownBig
- fadeOutLeft
- fadeOutLeftBig
- fadeOutRight
- fadeOutRightBig
- fadeOutUp
- fadeOutUpBig
- fadeOutTopLeft
- fadeOutTopRight
- fadeOutBottomLeft
- fadeOutBottomRight
</details>

## Use Your Own `ref`
Expand Down
15 changes: 15 additions & 0 deletions demo/Animations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ const Animations: FC = () => {
<option value="fadeInBottomLeft">fadeInBottomLeft</option>
<option value="fadeInBottomRight">fadeInBottomRight</option>
</optgroup>
<optgroup label="Fading exits">
<option value="fadeOut">fadeOut</option>
<option value="fadeOutDown">fadeOutDown</option>
<option value="fadeOutDownBig">fadeOutDownBig</option>
<option value="fadeOutLeft">fadeOutLeft</option>
<option value="fadeOutLeftBig">fadeOutLeftBig</option>
<option value="fadeOutRight">fadeOutRight</option>
<option value="fadeOutRightBig">fadeOutRightBig</option>
<option value="fadeOutUp">fadeOutUp</option>
<option value="fadeOutUpBig">fadeOutUpBig</option>
<option value="fadeOutTopLeft">fadeOutTopLeft</option>
<option value="fadeOutTopRight">fadeOutTopRight</option>
<option value="fadeOutBottomLeft">fadeOutBottomLeft</option>
<option value="fadeOutBottomRight">fadeOutBottomRight</option>
</optgroup>
</select>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions demo/Animations/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const target = css`
font-size: 5rem;
background: #333;
cursor: pointer;
z-index: 1;
&:focus {
outline: none;
}
Expand Down
4 changes: 4 additions & 0 deletions src/animations/fadeOut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
keyframes: [{ opacity: 1 }, { opacity: 0 }],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutBottomLeft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(-100%, 100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutBottomRight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(100%, 100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutDown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(0, 100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutDownBig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(0, 2000px, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutLeft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(-100%, 0, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutLeftBig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(-2000px, 0, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutRight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(100%, 0, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutRightBig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(2000px, 0, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutTopLeft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(-100%, -100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutTopRight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(100%, -100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutUp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(0, -100%, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
7 changes: 7 additions & 0 deletions src/animations/fadeOutUpBig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
keyframes: [
{ transform: "translate3d(0, 0, 0)", opacity: 1 },
{ transform: "translate3d(0, -2000px, 0)", opacity: 0 },
],
timing: { duration: 1000, fill: "both" },
};
13 changes: 13 additions & 0 deletions src/animations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ export { default as fadeInTopLeft } from "./fadeInTopLeft";
export { default as fadeInTopRight } from "./fadeInTopRight";
export { default as fadeInBottomLeft } from "./fadeInBottomLeft";
export { default as fadeInBottomRight } from "./fadeInBottomRight";
export { default as fadeOut } from "./fadeOut";
export { default as fadeOutDown } from "./fadeOutDown";
export { default as fadeOutDownBig } from "./fadeOutDownBig";
export { default as fadeOutLeft } from "./fadeOutLeft";
export { default as fadeOutLeftBig } from "./fadeOutLeftBig";
export { default as fadeOutRight } from "./fadeOutRight";
export { default as fadeOutRightBig } from "./fadeOutRightBig";
export { default as fadeOutUp } from "./fadeOutUp";
export { default as fadeOutUpBig } from "./fadeOutUpBig";
export { default as fadeOutTopLeft } from "./fadeOutTopLeft";
export { default as fadeOutTopRight } from "./fadeOutTopRight";
export { default as fadeOutBottomLeft } from "./fadeOutBottomLeft";
export { default as fadeOutBottomRight } from "./fadeOutBottomRight";

0 comments on commit 6eec3e6

Please sign in to comment.