Skip to content

Commit 30bb68a

Browse files
committed
Fix scroll position bug
1 parent 1749899 commit 30bb68a

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

example/public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="theme-color" content="#000000" />
88
<meta
99
name="description"
10-
content="Web site created using create-react-app"
10+
content="Declarative routing library for React ⚛ with page transitions and animations. Under Development 🧪. Web site created using create-react-app"
1111
/>
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1313
<!--
@@ -24,7 +24,7 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>React App</title>
27+
<title>React Motion Router</title>
2828
</head>
2929
<body>
3030
<noscript>You need to enable JavaScript to run this app.</noscript>

example/src/Components/Navbar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
33
import IconButton from '@mui/material/IconButton';
4-
import {Navigation} from 'react-motion-router';
54
import '../css/Navbar.css';
65

76
interface NavbarProps {

example/src/Screens/Cards.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Cards(props: CardsProps) {
2020
{
2121
Heroes.map((hero: Hero, index) => {
2222
return (
23-
<ButtonBase onClick={() => props.navigation.navigate('/details', {
23+
<ButtonBase key={index} onClick={() => props.navigation.navigate('/details', {
2424
profile: hero
2525
})}>
2626
<Card sx={{ width: 345 }}>
@@ -36,13 +36,7 @@ export default function Cards(props: CardsProps) {
3636
<SharedElement id={`title-${hero.id}`}>
3737
<Typography gutterBottom variant="h5" component="h5">{hero.name}</Typography>
3838
</SharedElement>
39-
{
40-
hero.description ?
41-
<SharedElement id={`desc-${hero.id}`}>
42-
<p>{hero.description}</p>
43-
</SharedElement>
44-
: undefined
45-
}
39+
<p>{hero.description}</p>
4640
</CardContent>
4741
</Card>
4842
</ButtonBase>

example/src/Screens/Details.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export default function Details(props: DetailsProps) {
3838
<SharedElement id={`title-${props.route.params.profile.id}`}>
3939
<h1>{props.route.params.profile.name}</h1>
4040
</SharedElement>
41-
<SharedElement id={`desc-${props.route.params.profile.id}`}>
42-
<p>{props.route.params.profile.description}</p>
43-
</SharedElement>
41+
<p>{props.route.params.profile.description}</p>
4442
</div>
4543
</div>
4644
</div>

example/src/Screens/Slides.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {useState} from 'react';
2-
import { Heroes, Hero } from '../assets/Heroes';
2+
import { Heroes } from '../assets/Heroes';
33
import ClearIcon from '@mui/icons-material/Clear';
44
import { Navigation, SharedElement } from 'react-motion-router';
55
import IconButton from '@mui/material/IconButton';

example/src/css/Details.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@
2626
text-align: justify;
2727
line-height: 1.5rem;
2828
height: 100%;
29+
}
30+
.details .text-content p {
31+
animation: slide-up 300ms ease-out;
32+
}
33+
34+
@keyframes slide-up {
35+
from {
36+
opacity: 0;
37+
transform: translateY(15px);
38+
}
39+
to {
40+
opacity: 1;
41+
transform: translateY(0px);
42+
}
2943
}

0 commit comments

Comments
 (0)