2016-06-04 3 views
1

React Native가 포함 된 Animated을 사용하는 애니메이션은 상당히 커질 수 있으며 특히 많은 파일이있는 경우 많은 공간을 차지할 수 있습니다. 별도의 파일에 포함시킬 수있는 방법이 있습니까? 그렇다면 어떻게 호출할까요?네이티브 애니메이션을 별도의 파일로 처리하십시오.

Animated.sequence([ 
    Animated.timing(this.state.move,{ 
    toValue: {x: 50, y: 100}, 
    duration:400 
    }), 
    Animated.timing(this.state.move,{ 
    toValue: {x: 0, y: 0, 
    duration:400,delay:400 
}), 
]).start() 

답변

0

저는 어떻게하는지 알아 냈습니다.

import React, { Component } from 'react'; 
import { 
    Animated, 
} from 'react-native'; 

var Anims = { 
firstAnim(move) { 
Animated.sequence([ 
    Animated.timing(move,{ 
    toValue: {x: 50, y: 100}, 
    duration:400 
    }), 
    Animated.timing(move,{ 
    toValue: {x: 0, y: 0, 
    duration:400,delay:400 
    }), 
    ]).start() 
    } 
} 

module.exports = Anims; 

는 다음과 같은 것이 필요합니다 :이 같은 별도의 파일 만들기

const Animations=require('./animations.js'); 

을 그리고 다음과 같이 호출 :

Animations.firstAnim(this.state.move); 
관련 문제