forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: ValueAnimatedNode.java -> ValueAnimatedNode.kt changelog: [internal] internal Differential Revision: D60188318
- Loading branch information
1 parent
98e1104
commit 0198903
Showing
2 changed files
with
65 additions
and
66 deletions.
There are no files selected for viewing
66 changes: 0 additions & 66 deletions
66
...eact-native/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
.../react-native/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.animated | ||
|
||
import com.facebook.react.bridge.ReadableMap | ||
|
||
/** | ||
* Basic type of animated node that maps directly from {@code Animated.Value(x)} of Animated.js | ||
* library. | ||
*/ | ||
internal open class ValueAnimatedNode : AnimatedNode { | ||
@JvmField internal var mValue: Double = Double.NaN | ||
@JvmField internal var mOffset: Double = 0.0 | ||
private var mValueListener: AnimatedNodeValueListener? = null | ||
|
||
public constructor() : super() { | ||
// empty constructor that can be used by subclasses | ||
} | ||
|
||
public constructor(config: ReadableMap) : super() { | ||
mValue = config.getDouble("value") | ||
mOffset = config.getDouble("offset") | ||
} | ||
|
||
public fun getValue(): Double { | ||
if ((mOffset + mValue).isNaN()) { | ||
this.update() | ||
} | ||
return mOffset + mValue | ||
} | ||
|
||
open fun getAnimatedObject(): Any? { | ||
return null | ||
} | ||
|
||
public fun flattenOffset(): Unit { | ||
mValue += mOffset | ||
mOffset = 0.0 | ||
} | ||
|
||
public fun extractOffset(): Unit { | ||
mOffset += mValue | ||
mValue = 0.0 | ||
} | ||
|
||
public fun onValueUpdate(): Unit { | ||
if (mValueListener == null) { | ||
return | ||
} | ||
requireNotNull(mValueListener).onValueUpdate(getValue()) | ||
} | ||
|
||
public fun setValueListener(listener: AnimatedNodeValueListener?): Unit { | ||
mValueListener = listener | ||
} | ||
|
||
override public fun prettyPrint(): String { | ||
return "ValueAnimatedNode[$mTag]: value: $mValue offset: $mOffset" | ||
} | ||
} |