()
| 77 | } |
| 78 | |
| 79 | export const SpringRef = < |
| 80 | State extends Lookup = Lookup, |
| 81 | >(): SpringRef<State> => { |
| 82 | const current: Controller<State>[] = [] |
| 83 | |
| 84 | const SpringRef: SpringRef<State> = function (props) { |
| 85 | deprecateDirectCall() |
| 86 | |
| 87 | const results: AsyncResult[] = [] |
| 88 | |
| 89 | each(current, (ctrl, i) => { |
| 90 | if (is.und(props)) { |
| 91 | results.push(ctrl.start()) |
| 92 | } else { |
| 93 | const update = _getProps(props, ctrl, i) |
| 94 | if (update) { |
| 95 | results.push(ctrl.start(update)) |
| 96 | } |
| 97 | } |
| 98 | }) |
| 99 | |
| 100 | return results |
| 101 | } |
| 102 | |
| 103 | SpringRef.current = current |
| 104 | |
| 105 | /** Add a controller to this ref */ |
| 106 | SpringRef.add = function (ctrl: Controller<State>) { |
| 107 | if (!current.includes(ctrl)) { |
| 108 | current.push(ctrl) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /** Remove a controller from this ref */ |
| 113 | SpringRef.delete = function (ctrl: Controller<State>) { |
| 114 | const i = current.indexOf(ctrl) |
| 115 | if (~i) current.splice(i, 1) |
| 116 | } |
| 117 | |
| 118 | /** Pause all animations. */ |
| 119 | SpringRef.pause = function () { |
| 120 | each(current, ctrl => ctrl.pause(...arguments)) |
| 121 | return this |
| 122 | } |
| 123 | |
| 124 | /** Resume all animations. */ |
| 125 | SpringRef.resume = function () { |
| 126 | each(current, ctrl => ctrl.resume(...arguments)) |
| 127 | return this |
| 128 | } |
| 129 | |
| 130 | /** Update the state of each controller without animating. */ |
| 131 | SpringRef.set = function ( |
| 132 | values: |
| 133 | | Partial<State> |
| 134 | | ((i: number, ctrl: Controller<State>) => Partial<State>) |
| 135 | ) { |
| 136 | each(current, (ctrl, i) => { |
no test coverage detected
searching dependent graphs…