2015-03-10 21:23:03 +00:00
|
|
|
/**
|
2015-03-23 20:35:08 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
2015-03-10 21:23:03 +00:00
|
|
|
*
|
2015-04-04 18:38:09 +00:00
|
|
|
* @providesModule AnimationExperimental
|
2015-03-10 21:23:03 +00:00
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-04-04 18:38:09 +00:00
|
|
|
var RCTAnimationManager = require('NativeModules').AnimationExperimentalManager;
|
2015-03-10 21:23:03 +00:00
|
|
|
var AnimationUtils = require('AnimationUtils');
|
|
|
|
|
|
|
|
type EasingFunction = (t: number) => number;
|
|
|
|
|
2015-04-04 18:38:09 +00:00
|
|
|
/**
|
|
|
|
* This is an experimental module that is under development, incomplete,
|
|
|
|
* potentially buggy, not used in any production apps, and will probably change
|
|
|
|
* in non-backward compatible ways.
|
|
|
|
*
|
|
|
|
* Use at your own risk.
|
|
|
|
*/
|
|
|
|
var AnimationExperimental = {
|
|
|
|
Mixin: require('AnimationExperimentalMixin'),
|
2015-03-10 21:23:03 +00:00
|
|
|
|
|
|
|
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-04-04 18:38:09 +00:00
|
|
|
var tag: number = RCTAnimationManager.startAnimation(
|
|
|
|
nodeHandle,
|
|
|
|
AnimationUtils.allocateTag(),
|
|
|
|
duration,
|
|
|
|
delay,
|
|
|
|
easingSample,
|
|
|
|
properties
|
|
|
|
);
|
2015-03-13 22:30:29 +00:00
|
|
|
return tag;
|
2015-03-10 21:23:03 +00:00
|
|
|
},
|
|
|
|
|
2015-03-13 22:30:29 +00:00
|
|
|
stopAnimation: function(tag: number) {
|
2015-03-10 21:23:03 +00:00
|
|
|
RCTAnimationManager.stopAnimation(tag);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-04-04 18:38:09 +00:00
|
|
|
module.exports = AnimationExperimental;
|