Download react-spring/targets/native/src/AnimatedTransform.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 998 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/targets/native/src/AnimatedTransform.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/targets/native/src/AnimatedTransform.ts
-
curl -L -o AnimatedTransform.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/targets/native/src/AnimatedTransform.ts
998 Bytes
| import { each, eachProp, getFluidValue } from '@react-spring/shared' | |
| import { Animated, AnimatedValue, AnimatedObject } from '@react-spring/animated' | |
| type Transform = { [key: string]: string | number | Animated } | |
| type Source = Transform[] | |
| export class AnimatedTransform extends AnimatedObject { | |
| declare protected source: Source | |
| constructor(source: Source) { | |
| super(source) | |
| } | |
| getValue() { | |
| return this.source | |
| ? this.source.map(source => { | |
| const transform: any = {} | |
| eachProp(source, (source, key) => { | |
| transform[key] = getFluidValue(source) | |
| }) | |
| return transform | |
| }) | |
| : [] | |
| } | |
| setValue(source: Source) { | |
| this.source = source | |
| this.payload = this._makePayload(source) | |
| } | |
| protected _makePayload(source: Source) { | |
| if (!source) return [] | |
| const payload = new Set<AnimatedValue>() | |
| each(source, transform => eachProp(transform, this._addToPayload, payload)) | |
| return Array.from(payload) | |
| } | |
| } | |