Skip to content

Instantly share code, notes, and snippets.

View xotahal's full-sized avatar
🏠
Working from home

Jiří Otáhal xotahal

🏠
Working from home
View GitHub Profile
<ColumnChart
height={200}
width={300}
data={data}
onPress={onPress}
/>
// Detail page with a destination shared element
import { SharedElement } from 'react-native-motion';
class DetailPage extends Component {
render() {
return (
<SharedElement sourceId="source">
<View>{listItemNode}</View>
</SharedElement>
);
// List items page with source of SharedElement
import { SharedElement } from 'react-native-motion';
class ListPage extends Component {
render() {
return (
<SharedElement id="source">
<View>{listItemNode}</View>
</SharedElement>
);
import { TranslateYAndOpacity } from 'react-native-motion';
class ToolbarTitle extends PureComponent {
render() {
return (
<TranslateYAndOpacity duration={250}>
<View>
// ...
</View>
</TranslateYAndOpacity>
class TranslateYAndOpacity extends PureComponent {
constructor(props) {
// ...
this.state = {
opacityValue: new Animated.Value(opacityMin),
translateYValue: new Animated.Value(translateYMin),
};
// ...
}
componentDidMount() {
/**
* Removes non alphanumeric characters.
*/
function normalize(phrase) {
if (!phrase) {
return '';
}
return phrase.replace(/[\W_]/g, '').toLowerCase();
}
/**
* Removes non alphanumeric characters.
*/
function normalize(phrase) {
if (!phrase) {
return '';
}
return phrase.replace(/[\W_]/g, '').toLowerCase();
}
/**
* Removes non alphanumeric characters.
*/
function normalize(phrase) {
if (!phrase) {
return '';
}
return phrase.replace(/[\W_]/g, '').toLowerCase();
}
onPressOut = () => {
// When user use onPress all animation happens in onPress method. But when user use long
// press. We displaye background layer in onLongPress and then we need to animate ripple
// effect that is done here.
Animated.parallel([
// Hide opacity background layer, slowly. It has to be done later than ripple
// effect
Animated.timing(this.state.opacityBackgroundValue, {
toValue: 0,
duration: 500 + diameter,
onLongPress = () => {
// Animation of long press is slightly different than onPress animation
Animated.timing(this.state.opacityBackgroundValue, {
toValue: maxOpacity / 2,
duration: 700,
}).start();
}