react-native-animated-spinkit
Version:
A pure JavaScript port of SpinKit for React Native.
59 lines (55 loc) • 2.02 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Animated, View } from 'react-native';
import { defaultProps } from './SpinnerProps';
import AnimationContainer from './AnimationContainer';
import { stagger } from './utils';
export default class Bounce extends React.Component {
render() {
const {
size,
color,
style,
animating,
hidesWhenStopped,
...rest
} = this.props;
const circleStyle = {
position: 'absolute',
width: size,
height: size,
backgroundColor: color,
borderRadius: size / 2,
opacity: 0.6
};
return /*#__PURE__*/React.createElement(AnimationContainer, {
initAnimation: () => ({
bounce: value => stagger(1000, 2, {
duration: 2000,
value: value,
keyframes: [0, 45, 55, 100]
})
}),
animating: animating
}, values => /*#__PURE__*/React.createElement(View, _extends({
style: [{
width: size,
height: size,
opacity: !animating && hidesWhenStopped ? 0 : 1
}, style]
}, rest), values.bounce.map((value, index) => /*#__PURE__*/React.createElement(Animated.View, {
key: index,
style: [circleStyle, {
transform: [{
scale: value.interpolate({
inputRange: [0, 45, 55, 100],
outputRange: [0.01, 1, 1, 0.01]
})
}]
}]
}))));
}
}
_defineProperty(Bounce, "defaultProps", defaultProps);
//# sourceMappingURL=Bounce.js.map