Skip to content

Commit

Permalink
Convert TrackingAnimatedNode to Kotlin
Browse files Browse the repository at this point in the history
Differential Revision: D60286293
  • Loading branch information
rshest authored and facebook-github-bot committed Jul 26, 2024
1 parent 02e950d commit 2210b33
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 50 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.JavaOnlyMap
import com.facebook.react.bridge.ReadableMap

internal class TrackingAnimatedNode(
config: ReadableMap,
private val nativeAnimatedNodesManager: NativeAnimatedNodesManager
) : AnimatedNode() {
private val animationId: Int = config.getInt("animationId")
private val toValueNode: Int = config.getInt("toValue")
private val valueNode: Int = config.getInt("value")
private val animationConfig: JavaOnlyMap = JavaOnlyMap.deepClone(config.getMap("animationConfig"))

public override fun update() {
val toValue = nativeAnimatedNodesManager.getNodeById(toValueNode)
val valAnimatedNode = toValue as? ValueAnimatedNode
if (valAnimatedNode != null) {
animationConfig.putDouble("toValue", valAnimatedNode.value)
} else {
animationConfig.putNull("toValue")
}
nativeAnimatedNodesManager.startAnimatingNode(animationId, valueNode, animationConfig, null)
}

public override fun prettyPrint(): String =
"TrackingAnimatedNode[$mTag]: animationID: $animationId toValueNode: $toValueNode " +
"valueNode: $valueNode animationConfig: $animationConfig"
}

0 comments on commit 2210b33

Please sign in to comment.