viewstools / animations Goto Github PK
View Code? Open in Web Editor NEWViews animations wrapper around react-spring
Views animations wrapper around react-spring
I think something has changed in react-spring
...
So, say I have this view:
App Vertical
marginTop 100
onClick <
width 100
backgroundColor #ffaa00
when <isClicked
width 150 spring bounciness 20 speed 20
Label Text
text Hi
If I morph it as native I get this:
/* eslint-disable jsx-a11y/accessible-emoji, no-unused-vars */
import React from 'react';
import {
Animated,
StyleSheet,
Text,
TouchableWithoutFeedback,
} from 'react-native';
import { Spring } from '@viewstools/animations/native';
const styles = StyleSheet.create({
App1: { marginTop: 100, backgroundColor: '#ffaa00' },
});
class App extends React.Component {
render() {
const { props } = this;
return (
<Spring
bounciness={20}
speed={20}
delay={0}
to={{ width: props.isClicked ? 150 : 100 }}
>
{animatedApp => (
<TouchableWithoutFeedback
activeOpacity={0.7}
onPress={props.onClick}
underlayColor="transparent"
>
<Animated.View
testID={`${props['testID'] || 'App'}|${
props.isClicked ? 'isClicked|' : ''
}`}
style={[styles.App1, { width: animatedApp.width }]}
>
<Text testID={`App.Label|`}>Hi</Text>
{props.children}
</Animated.View>
</TouchableWithoutFeedback>
)}
</Spring>
);
}
}
export default App;
It renders fine, but when I try to click on the button I get this:
According to this we should use regular RN components and extend them with animated(Component), like this const SpringView = animated(View)
but for that to work I had to
Spring
component directly from react-spring
styleSheet.create
.Here's what worked for me:
/* eslint-disable jsx-a11y/accessible-emoji, no-unused-vars */
import React from 'react';
import {
Text,
TouchableWithoutFeedback,
View
} from 'react-native';
import { Spring, animated } from 'react-spring/dist/native.cjs';
const SpringView = animated(View)
class App extends React.Component {
render() {
const { props } = this;
return (
<Spring
native
bounciness={20}
speed={20}
delay={0}
to={{ width: props.isClicked ? 150 : 100 }}
>
{animatedApp => (
<TouchableWithoutFeedback
activeOpacity={0.7}
onPress={props.onClick}
underlayColor="transparent"
>
<SpringView
testID={`${props['testID'] || 'App'}|${
props.isClicked ? 'isClicked|' : ''
}`}
style={{ marginTop: 100, backgroundColor: '#ffaa00', width: animatedApp.width }}
>
<Text testID={`App.Label|`}>Hi</Text>
{props.children}
</SpringView>
</TouchableWithoutFeedback>
)}
</Spring>
);
}
}
export default App;
I guess it needs work on this repo and on the morpher. Happy to do it obviously but we should proabbly have a chat about it first, when you some time in a couple of weeks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.