oblador / react-native-animatable

Standard set of easy to use animations and declarative transitions for React Native
MIT License
9.82k stars 701 forks source link

Custom Component animation #81

Open Ileezyy opened 7 years ago

Ileezyy commented 7 years ago

Hi. Simply awesome library! Thank you! But I have a question about custom component animation. Could you write in details how to apply this piece of code: MyCustomComponent = Animatable.createAnimatableComponent(MyCustomComponent);

Thank you once more.

oblador commented 7 years ago

Not exactly sure of your question, but it's good practice to save your animatable component to a new variable: const AnimatableMyCustomComponent = Animatable.createAnimatableComponent(MyCustomComponent);

ddwhan0123 commented 7 years ago

I have the same question about my custom component. My code like this

import React, {Component, Navigator} from 'react';
import {
    AppRegistry,
    StyleSheet,
    BackAndroid,
    Platform,
    Text,
    View,
    ToastAndroid,
} from 'react-native';
import MyCustomSquare from '../widget/MyCustomSquare';
import * as Animatable from 'react-native-animatable';

var _navigator;
var title;
const NewSquare = Animatable.createAnimatableComponent(MyCustomSquare);

export default class Touch extends Component{
    constructor(props){
      super(props);
      _navigator=this.props._navigator;
      title=this.props.title;
    }

    render(){
      return(
        <View style={{flex : 1, flexDirection :'column'}}>
          <Text style={{
              fontSize: 20,
              color: 'green'}}
            >{title}
              View
          </Text>
          <NewSquare
            animation="bounceInUp"
            duration={1100}
            delay={1400}
          />
        <Animatable.Text animation="slideInDown" iterationCount="infinite" direction="alternate">Up and down</Animatable.Text>
        </View>

      );
    }
}

But the NewSquare have no anim

thanks

oblador commented 7 years ago

Hi, does your component accept the style prop?

kaplanitay commented 7 years ago

Hi, having the same issue.. my component does not accept style prop...

ddwhan0123 commented 7 years ago

@oblador Yes , I think so

singhsurbhidaffodil commented 6 years ago

Hi, got the same issue, not able to animate custom components