mirror of
https://github.com/zhigang1992/react-native-reanimated.git
synced 2026-01-12 22:50:47 +08:00
The main problems were with setValue and interpolate so I made them not available internally and exposed it with addition class. In internal operation InternalAnimatedValue is used and it's not causing dependencies' cycles. Changed logic of exposing nodes. Now there's no need to import whole base.js for wrapped nodes.
41 lines
960 B
JavaScript
41 lines
960 B
JavaScript
import { val } from '../val';
|
|
import AnimatedNode from './AnimatedNode';
|
|
import { adapt } from '../core/AnimatedBlock';
|
|
|
|
class AnimatedCond extends AnimatedNode {
|
|
_condition;
|
|
_ifBlock;
|
|
_elseBlock;
|
|
|
|
constructor(condition, ifBlock, elseBlock) {
|
|
super(
|
|
{
|
|
type: 'cond',
|
|
cond: condition.__nodeID,
|
|
ifBlock: ifBlock.__nodeID,
|
|
elseBlock: elseBlock ? elseBlock.__nodeID : undefined,
|
|
},
|
|
[condition, ifBlock, elseBlock]
|
|
);
|
|
this._condition = condition;
|
|
this._ifBlock = ifBlock;
|
|
this._elseBlock = elseBlock;
|
|
}
|
|
|
|
__onEvaluate() {
|
|
if (val(this._condition)) {
|
|
return val(this._ifBlock);
|
|
} else {
|
|
return this._elseBlock !== undefined ? val(this._elseBlock) : undefined;
|
|
}
|
|
}
|
|
}
|
|
|
|
export function createAnimatedCond(cond, ifBlock, elseBlock) {
|
|
return new AnimatedCond(
|
|
adapt(cond),
|
|
adapt(ifBlock),
|
|
elseBlock === undefined ? undefined : adapt(elseBlock)
|
|
);
|
|
}
|