mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 17:46:35 +08:00
Summary:This change extends animated native module API with `stopAnimation` method that is responsible for interrupting actively running animation as a reslut of a JS call. In order for the `stopAnimation` to understand `animationId` argument I also had to add `animationId` to `startAnimation` method. As JS thread runs in parallel to the thread which executes the animation there is a chance that JS may call `stopAnimation` after the animation has finished. Because of that we are not doing any checks on the `animationId` parameter passed to `stopAnimation` in native and if the animation does not exists in the registry we ignore that call. **Test Plan** Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js` Run java tests: `buck test ReactAndroid/src/test/java/com/facebook/react/animated` Closes https://github.com/facebook/react-native/pull/7058 Differential Revision: D3211906 fb-gh-sync-id: 3761509651de36a550b00d33e2a631c379d3900f fbshipit-source-id: 3761509651de36a550b00d33e2a631c379d3900f
31 lines
956 B
Java
31 lines
956 B
Java
/**
|
|
* 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.
|
|
*/
|
|
|
|
package com.facebook.react.animated;
|
|
|
|
import com.facebook.react.bridge.Callback;
|
|
|
|
/**
|
|
* Base class for different types of animation drivers. Can be used to implement simple time-based
|
|
* animations as well as spring based animations.
|
|
*/
|
|
/*package*/ abstract class AnimationDriver {
|
|
|
|
/*package*/ boolean mHasFinished = false;
|
|
/*package*/ ValueAnimatedNode mAnimatedValue;
|
|
/*package*/ Callback mEndCallback;
|
|
/*package*/ int mId;
|
|
|
|
/**
|
|
* This method gets called in the main animation loop with a frame time passed down from the
|
|
* android choreographer callback.
|
|
*/
|
|
public abstract void runAnimationStep(long frameTimeNanos);
|
|
}
|