in interface design, as one of the most important tools of successful interaction. • It can be said that without animation, there cannot be interaction • Users have high expectations of the UI they use, specially nowadays where the high quality content is everywhere.
completing what they intended to do. • The best animations are those that seem natural • If you disable animations, the flow should feel broken. If it is not, this might mean your animations are superfluous
easy to concisely express a wide variety of interesting animation and interaction patterns in a very performant way. • Animated values bypass the usual render method, so they get updated even though there is no state change. • Animated exports four animatable component types: View, Text, Image and ScrollView.
known as static drivers: timing, spring, decay • Each type provides a particular animation curve that controls how your values animate from their initial to the final value.
translateX = new Animated.Value(0); • 2. Bind the value to the Animated View (inside Render) <Animated.View style={{ transform: [{ translateX }] }} /> • 3. Run the animation with the static driver Animated.timing(translateX, { toValue: 50, duration: 1000 }).start();
the string contains at least one number or is a color. • Numbers in the string are parsed and interpolated, then wrapped back in string again. • For rotation, we can use degrees or radians, i.e “360deg” or “1rad”
• It should change opacity from 1 to 0, • It should rotate from 0 to 90 degrees when it reaches half and from 90 to 360 degrees when it reaches the end • The animation should loop over 4 times. Loop time can be 4000ms • Don’t press the button for now!
every frame to update an animation, declare the animation configuration in JS and execute in UI thread on native. • As a consequence, JS thread can be blocked without affecting the animation. • Just add useNativeDriver: true to the animation config when starting it. Animated.timing(this.progress, { toValue: 1, duration: 1000, useNativeDriver: true // Add this line }).start();
• Things like transform and opacity will work, but flexbox and position properties will not • That’s why we were using transformX for moving the box horizontally. • Still without using native driver, animating transformX is more efficient than animating left, because with the former, the layout doesn’t have to be recalculated every frame
know what the value is at a given point in time • You can’t access the value synchronously through a public API this.progress.addListener(({ value }) => { // Do something with the value! });
animation from 0 to 1 (or any arbitrary range of numbers) • We can derive other values from the progress value with linear interpolation • Those values can be assigned to style properties on Animated Views • When the progress value updates, the interpolated values update and the views that are bound to those update • We can drive updates to the progress value using functions such as Animated.timing
events • Animate translation: Outside and inside the screen • A bit of manual work: Save offset (Y) and compare it to the listened value to know if we scroll up or down
instead of a JS based. • A Switch component is another example or native gesture recogniser where you can swipe or touch to flip the state • Drawer, NavigatorIOS, ViewPager…
run in parallel. 2. No API for defining interactions between native gesture recognisers, like a Drawer and a View Pager 3. Touch events recognised by JS responder system can’t be connected with Views that animate on the native thread
It provides a more comprehensive, low level abstraction • Great flexibility for gesture based animations • Everything runs on the native thread by default!