Last active
February 28, 2021 19:04
-
-
Save fabiomazucato/d13ada42330f9f88b5e1cf394652df02 to your computer and use it in GitHub Desktop.
Skeleton - Parte 2 (index.js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createElement, useState } from 'react' | |
import { Animated, Easing } from 'react-native' | |
import View from './view' | |
const SkeletonContainer = (props) => { | |
const { dimensions = [0, 0], circle = null, margin = [0, 0] } = props | |
const [animation] = useState(new Animated.Value(0.1)) | |
Animated.loop( | |
Animated.sequence([ | |
Animated.timing(animation, { | |
duration: 900, | |
toValue: 0.8, | |
easing: Easing.linear, | |
useNativeDriver: true | |
}), | |
Animated.timing(animation, { | |
duration: 900, | |
toValue: 0.3, | |
easing: Easing.linear, | |
useNativeDriver: true | |
}) | |
]) | |
).start() | |
const viewProps = { | |
animation, | |
marginHorizontal: margin[0], | |
marginVErtical: margin[1], | |
circle, | |
width: dimensions[0], | |
height: dimensions[1] | |
} | |
return createElement(View, viewProps) | |
} | |
export default SkeletonContainer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment