* Parse the `to` and `from` range from the given `props` object. * * This also ensures the initial value is available to animated components * during the render phase.
(props: {
to?: any
from?: any
reverse?: boolean
default?: any
})
| 526 | * during the render phase. |
| 527 | */ |
| 528 | protected _prepareNode(props: { |
| 529 | to?: any |
| 530 | from?: any |
| 531 | reverse?: boolean |
| 532 | default?: any |
| 533 | }) { |
| 534 | const key = this.key || '' |
| 535 | |
| 536 | let { to, from } = props |
| 537 | |
| 538 | to = is.obj(to) ? to[key] : to |
| 539 | if (to == null || isAsyncTo(to)) { |
| 540 | to = undefined |
| 541 | } |
| 542 | |
| 543 | from = is.obj(from) ? from[key] : from |
| 544 | if (from == null) { |
| 545 | from = undefined |
| 546 | } |
| 547 | |
| 548 | // Create the range now to avoid "reverse" logic. |
| 549 | const range = { to, from } |
| 550 | |
| 551 | // Before ever animating, this method ensures an `Animated` node |
| 552 | // exists and keeps its value in sync with the "from" prop. |
| 553 | if (!hasAnimated(this)) { |
| 554 | if (props.reverse) [to, from] = [from, to] |
| 555 | |
| 556 | from = getFluidValue(from) |
| 557 | if (!is.und(from)) { |
| 558 | this._set(from) |
| 559 | } |
| 560 | // Use the "to" value if our node is undefined. |
| 561 | else if (!getAnimated(this)) { |
| 562 | this._set(to) |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | return range |
| 567 | } |
| 568 | |
| 569 | /** Every update is processed by this method before merging. */ |
| 570 | protected _update( |
no test coverage detected