Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit ed08ff3

Browse files
committed
Merge pull request marnusw#8 from zabojad/master
Add Hardware Acceleration example to README
2 parents 7dd48ac + 1617247 commit ed08ff3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,46 @@ the duration of the transition. In this case:
134134
See the live example [here](http://marnusw.github.io/react-css-transition-replace#fade-wait).
135135

136136

137+
### Hardware acceleration for smoother transitions
138+
139+
For even smoother transitions, try to trigger hardware acceleration whenever possible. Here is an example of what you could do for a mobile app transition between pages:
140+
141+
```css
142+
.page-enter, .page-leave {
143+
position: absolute;
144+
-webkit-transition: transform 250ms ease-in-out, opacity 250ms ease-in-out;
145+
transition: transform 250ms ease-in-out, opacity 250ms ease-in-out;
146+
}
147+
148+
.page-enter {
149+
left: 100vw;
150+
}
151+
152+
.page-enter.page-enter-active {
153+
-webkit-transform: translate3d(-100vw, 0, 0);
154+
transform: translate3d(-100vw, 0, 0);
155+
}
156+
157+
.page-leave {
158+
left: 0;
159+
}
160+
161+
.page-leave.page-leave-active {
162+
-webkit-transform: translate3d(-100vw, 0, 0);
163+
transform: translate3d(-100vw, 0, 0);
164+
}
165+
```
166+
167+
```
168+
<ReactCSSTransitionReplace transitionName="page" transitionEnterTimeout={250} transitionLeaveTimeout={250} >
169+
<div key="page01">
170+
My page 01 content
171+
</div>
172+
</ReactCSSTransitionReplace>
173+
```
174+
175+
The use of translate3d instead of 2D translate will trigger hardware acceleration and make your transition even smoother.
176+
137177
## Tips
138178

139179
1. In general animating `block` or `inline-block` level elements is more stable that `inline` elements. If the

0 commit comments

Comments
 (0)