Skip to content

Commit 2980f1d

Browse files
committed
Fixed zoom animation bug
1 parent e046b18 commit 2980f1d

File tree

9 files changed

+28
-190
lines changed

9 files changed

+28
-190
lines changed

example/src/App.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import {Router, Stack} from 'react-motion-router';
33
import Home from './Screens/Home';
44
import Details from './Screens/Details';
5-
import Post from './Screens/Post';
65
import Tiles from './Screens/Tiles';
76
import Slides from './Screens/Slides';
87
import Cards from './Screens/Cards';
@@ -15,8 +14,7 @@ function App() {
1514
<div className="App">
1615
<Router config={{
1716
defaultRoute: '/',
18-
pageLoadTransition: false,
19-
disableDiscovery: !disableBrowserRouting,
17+
disableDiscovery: false,
2018
disableBrowserRouting: disableBrowserRouting,
2119
animation: {
2220
type: "slide",
@@ -42,11 +40,6 @@ function App() {
4240
path={"/"}
4341
component={Home}
4442
/>
45-
<Stack.Screen
46-
path={"/post"}
47-
component={Post}
48-
defaultParams={{data: "Default"}}
49-
/>
5043
<Stack.Screen
5144
path={"/tiles"}
5245
component={Tiles}

example/src/Screens/Post.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

example/src/assets/Posts.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/src/assets/Profiles.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/src/css/App.css

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -3,109 +3,4 @@
33
* {
44
margin: 0;
55
font-family: 'Roboto', sans-serif;
6-
}
7-
8-
.profile-card {
9-
width: max-content;
10-
padding: 15px;
11-
display: flex;
12-
gap: 15px;
13-
border-radius: 5px;
14-
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
15-
margin: 15px;
16-
17-
}
18-
.profile-card:hover, .post-card:hover {
19-
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.3);
20-
}
21-
.profile-description {
22-
display: flex;
23-
flex-direction: column;
24-
gap: 5px;
25-
max-width: 150px;
26-
}
27-
.profile-description p {
28-
width: 100%;
29-
text-overflow: ellipsis;
30-
overflow: hidden;
31-
white-space: nowrap;
32-
}
33-
.profile-card img {
34-
width: 64px;
35-
height: 64px;
36-
border-radius: 50%;
37-
object-fit: cover;
38-
}
39-
.profile-info {
40-
display: flex;
41-
flex-direction: column;
42-
max-width: 100vw;
43-
overflow-x: hidden;
44-
}
45-
.profile-info img {
46-
width: 100%;
47-
max-width: 1000px;
48-
height: auto;
49-
border-radius: 0;
50-
object-fit: cover;
51-
}
52-
.post-card {
53-
width: 250px;
54-
display: flex;
55-
flex-direction: column;
56-
align-items: center;
57-
gap: 10px;
58-
border-radius: 5px;
59-
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
60-
margin: 15px;
61-
padding-top: 5px;
62-
}
63-
.post-card img {
64-
width: 100%;
65-
height: auto;
66-
}
67-
68-
.post-card .post-description {
69-
height: 150px;
70-
padding: 15px;
71-
padding-top: 0;
72-
}
73-
.post-card .post-description p {
74-
height: 100%;
75-
text-overflow: ellipsis;
76-
overflow: hidden;
77-
}
78-
.post {
79-
display: flex;
80-
flex-direction: column;
81-
align-items: center;
82-
width: 100%;
83-
gap: 15px;
84-
}
85-
.post .picture {
86-
width: 100%;
87-
}
88-
.post .picture img {
89-
width: 100%;
90-
object-fit: cover;
91-
}
92-
.post .text {
93-
display: flex;
94-
flex-direction: column;
95-
gap: 15px;
96-
}
97-
98-
.post .text p {
99-
animation: slide-up 400ms ease-out;
100-
}
101-
102-
@keyframes slide-up {
103-
from {
104-
opacity: 0;
105-
transform: translateY(100%);
106-
}
107-
to {
108-
opacity: 1;
109-
transform: translateY(0px);
110-
}
111-
}
6+
}

example/src/css/Details.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
top: 0;
77
z-index: 1;
88
}
9-
@keyframes fade-in {
10-
from {
11-
opacity: 0;
12-
transform: translateY(-30px);
13-
}
14-
to {
15-
opacity: 1;
16-
transform: translateY(0px);
17-
}
18-
}
19-
209
.details .text-content {
2110
padding: 15px;
2211
}
@@ -46,4 +35,20 @@
4635
width: calc(100vw - 30px);
4736
display: flex;
4837
justify-content: center;
38+
}
39+
.details .profile-info {
40+
align-items: center;
41+
}
42+
.profile-info {
43+
display: flex;
44+
flex-direction: column;
45+
max-width: 100vw;
46+
overflow-x: hidden;
47+
}
48+
.profile-info img {
49+
width: 100%;
50+
max-width: 1000px;
51+
height: auto;
52+
border-radius: 0;
53+
object-fit: cover;
4954
}

src/AnimationLayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ export class AnimationProvider extends React.Component<AnimationProviderProps, A
410410
if (this._animationLayerData?.gestureNavigating && this.props.out) {
411411
gestureEndState = AnimationKeyframePresets[this.outAnimation as keyof typeof AnimationKeyframePresets][0];
412412
}
413-
414413
return (
415414
<div className="animation-provider" ref={this.setRef} style={{
416415
position: 'absolute',
416+
transformOrigin: 'center center',
417417
pointerEvents: this.state.pointerEvents,
418418
zIndex: this.props.in && !this.props.backNavigating ? 1 : this.props.out && this.props.backNavigating ? 1 : 0,
419419
...gestureEndState // so the "old" nextScreen doesn't snap back to centre

src/Animations.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,41 +132,41 @@ const Presets = {
132132
],
133133
"zoom-in-in": [
134134
{
135-
transform: 'scale(0.85)',
136-
opacity: 1
135+
transform: 'scale(0.85) translate(7.5vw, 7.5vh)',
136+
opacity: 0
137137
},
138138
{
139-
transform: 'scale(1)',
139+
transform: 'scale(1) translate(0vw, 0vh)',
140140
opacity: 1
141141
}
142142
],
143143
"zoom-in-out": [
144144
{
145-
transform: 'scale(1)',
145+
transform: 'scale(1) translate(0vw, 0vh)',
146146
opacity: 1
147147
},
148148
{
149-
transform: 'scale(1.15)',
149+
transform: 'scale(1.15) translate(-7.5vw, -7.5vh)',
150150
opacity: 0
151151
}
152152
],
153153
"zoom-out-in": [
154154
{
155-
transform: 'scale(1.15)',
155+
transform: 'scale(1.15) translate(-7.5vw, -7.5vh)',
156156
opacity: 0
157157
},
158158
{
159-
transform: 'scale(1)',
159+
transform: 'scale(1) translate(0vw, 0vh)',
160160
opacity: 1
161161
}
162162
],
163163
"zoom-out-out": [
164164
{
165-
transform: 'scale(1)',
165+
transform: 'scale(1) translate(0vw, 0vh)',
166166
opacity: 1
167167
},
168168
{
169-
transform: 'scale(0.85)',
169+
transform: 'scale(0.85) translate(7.5vw, 7.5vh)',
170170
opacity: 0
171171
}
172172
],

src/Router.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ interface Config {
3434
in: AnimationConfig;
3535
out?: AnimationConfig;
3636
} | AnimationConfig;
37-
pageLoadTransition?: boolean;
3837
defaultRoute?: string;
3938
swipeAreaWidth?: number;
4039
minFlingVelocity?: number;

0 commit comments

Comments
 (0)