2015-03-11 02:11:28 +00:00
|
|
|
/**
|
|
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* @providesModule Animation
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-18 22:57:49 +00:00
|
|
|
var RCTAnimationManager = require('NativeModules').AnimationManager;
|
2015-03-11 02:11:28 +00:00
|
|
|
var AnimationUtils = require('AnimationUtils');
|
|
|
|
|
|
|
|
type EasingFunction = (t: number) => number;
|
|
|
|
|
|
|
|
var Animation = {
|
|
|
|
Mixin: require('AnimationMixin'),
|
|
|
|
|
|
|
|
startAnimation: function(
|
|
|
|
node: any,
|
|
|
|
duration: number,
|
|
|
|
delay: number,
|
|
|
|
easing: (string | EasingFunction),
|
|
|
|
properties: {[key: string]: any}
|
|
|
|
): number {
|
|
|
|
var nodeHandle = +node.getNodeHandle();
|
|
|
|
var easingSample = AnimationUtils.evaluateEasingFunction(duration, easing);
|
2015-03-14 17:52:40 +00:00
|
|
|
var tag: number = RCTAnimationManager.startAnimation(nodeHandle, AnimationUtils.allocateTag(), duration, delay, easingSample, properties);
|
|
|
|
return tag;
|
2015-03-11 02:11:28 +00:00
|
|
|
},
|
|
|
|
|
2015-03-14 17:52:40 +00:00
|
|
|
stopAnimation: function(tag: number) {
|
2015-03-11 02:11:28 +00:00
|
|
|
RCTAnimationManager.stopAnimation(tag);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Animation;
|