You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The basic building block of this library is <code>Animated.Value</code>. This is a variable that's going to drive the animation. You use it like a normal value in <code>style</code> attribute. Only animated components such as <code>Animated.div</code> will understand it.</p>
258
258
259
259
<scripttype="text/babel">
260
-
examplify(React.createClass({
260
+
examplify(createClass({
261
261
getInitialState: function(){
262
262
return{
263
263
anim: newAnimated.Value(100),
@@ -281,7 +281,7 @@ <h2>setValue</h2>
281
281
<p>The <code>Animated.div</code> component when rendered tracks which animated values it received. This way, whenever that value changes, we don't need to re-render the entire component, we can directly update the specific style attribute that changed.</p>
282
282
283
283
<scripttype="text/babel">
284
-
examplify(React.createClass({
284
+
examplify(createClass({
285
285
getInitialState: function(){
286
286
return{
287
287
anim: newAnimated.Value(0),
@@ -310,7 +310,7 @@ <h2>Animated.timing</h2>
310
310
<p>On every frame (via <code>requestAnimationFrame</code>), the <code>timing</code> animation is going to figure out the new value based on the current time, update the animated value which in turn is going to update the corresponding DOM node.</p>
311
311
312
312
<scripttype="text/babel">
313
-
examplify(React.createClass({
313
+
examplify(createClass({
314
314
getInitialState: function(){
315
315
return{
316
316
anim: newAnimated.Value(0),
@@ -339,7 +339,7 @@ <h2>Interrupt Animations</h2>
339
339
<p>There are multiple challenges to implement this correctly. You need to stop the current animation, grab the current value and restart an animation from there. As this is pretty tedious to do manually, <code>Animated</code> will do that automatically for you.</p>
340
340
341
341
<scripttype="text/babel">
342
-
examplify(React.createClass({
342
+
examplify(createClass({
343
343
getInitialState: function(){
344
344
return{
345
345
anim: newAnimated.Value(1),
@@ -374,7 +374,7 @@ <h2>Animated.spring</h2>
374
374
<p>It turns out that this model is useful in a very wide range of animations. I highly recommend you to always start with a <code>spring</code> animation instead of a <code>timing</code> animation. It will make your interface feels much better.</p>
375
375
376
376
<scripttype="text/babel">
377
-
examplify(React.createClass({
377
+
examplify(createClass({
378
378
getInitialState: function(){
379
379
return{
380
380
anim: newAnimated.Value(1),
@@ -409,7 +409,7 @@ <h2>interpolate</h2>
409
409
<p>In the following example, we're going to model the animation with a variable where 1 means fully visible and 0 means fully hidden. We can pass it directly to the scale attribute as the ranges match. But for the rotation, we need to convert [0 ; 1] range to [260deg ; 0deg]. This is where <code>interpolate()</code> comes handy.</p>
410
410
411
411
<scripttype="text/babel">
412
-
examplify(React.createClass({
412
+
examplify(createClass({
413
413
getInitialState: function(){
414
414
return{
415
415
anim: newAnimated.Value(1),
@@ -453,7 +453,7 @@ <h2>stopAnimation</h2>
453
453
<p>There's however one exception: when you want to stop the current animation. You need to know where it stopped in order to continue from there. We cannot know the value synchronously so we give it via a callback in <code>stopAnimation</code>. It will not suffer from beign out of sync since the animation is no longer running.</p>
454
454
455
455
<scripttype="text/babel">
456
-
examplify(React.createClass({
456
+
examplify(createClass({
457
457
getInitialState: function(){
458
458
return{
459
459
anim: newAnimated.Value(0)
@@ -503,7 +503,7 @@ <h2>HorizontalPan</h2>
503
503
<p>We introduce a little helper called <code>HorizontalPan</code> which handles all this annoying code for us. It takes an <code>Animated.Value</code> as first argument and returns the event handlers required for it to work. We just have to bind this value to the <code>left</code> attribute and we're good to go.</p>
504
504
505
505
<scripttype="text/babel">
506
-
examplify(React.createClass({
506
+
examplify(createClass({
507
507
getInitialState: function(){
508
508
return{
509
509
anim: newAnimated.Value(0),
@@ -529,7 +529,7 @@ <h2>Animated.decay</h2>
529
529
<p>In order to implement this effect, we are using a second real-world simulation: an object moving on an icy surface. All it needs is two values: the current velocity and a deceleration coefficient. It is implemented by <code>Animated.decay</code>.</p>
530
530
531
531
<scripttype="text/babel">
532
-
examplify(React.createClass({
532
+
examplify(createClass({
533
533
getInitialState: function(){
534
534
return{
535
535
anim: newAnimated.Value(0),
@@ -558,7 +558,7 @@ <h2>Animation Chaining</h2>
558
558
<p>The target for an animation is usually a number but sometimes it is convenient to use another value as a target. This way, the first value will track the second. Using a spring animation, we can get a nice trailing effect.</p>
0 commit comments