UNPKG

react-native-fiesta

Version:

A set of celebration animations powered by Skia. Engage more with your users by celebrating in your React Native application.

67 lines (66 loc) 2.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Balloon = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNativeSkia = require("@shopify/react-native-skia"); var _reactNativeReanimated = require("react-native-reanimated"); var _theming = require("../constants/theming"); var _speed = require("../constants/speed"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } const Balloon = exports.Balloon = /*#__PURE__*/(0, _react.memo)(({ x = 0, y = 0, color = '#A555EC', r = 40, depth = 1, autoPlay = true }) => { const opacity = (0, _reactNativeReanimated.useSharedValue)(1); const stringRotation = (0, _reactNativeReanimated.useSharedValue)(-0.05); (0, _react.useEffect)(() => { opacity.value = (0, _reactNativeReanimated.withSpring)(autoPlay ? 0 : 1, _speed.singleItemFadeSpeed); stringRotation.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(0.05, { duration: 500, easing: _reactNativeReanimated.Easing.linear }), -1, true); }, [autoPlay, opacity, stringRotation]); const matrix = (0, _reactNativeReanimated.useDerivedValue)(() => [{ scale: depth }, { translateX: x }, { translateY: y }, { rotate: stringRotation.value }]); return /*#__PURE__*/_react.default.createElement(_reactNativeSkia.Group, { transform: matrix, opacity: opacity }, /*#__PURE__*/_react.default.createElement(_reactNativeSkia.Path, { path: `M 100 22 C 90 10, 110 80, 100 100 S 100 170, 100 150`, color: _theming.baseColors.golden, style: "stroke", strokeJoin: "round", strokeWidth: 5, transform: [{ translateX: -55 }] }), /*#__PURE__*/_react.default.createElement(_reactNativeSkia.Oval, { height: r * 2.3, width: r * 2, color: color, transform: [{ translateY: -50 }] }), /*#__PURE__*/_react.default.createElement(_reactNativeSkia.Circle, { cx: r / 0.8, cy: -25, r: r / 4, color: _theming.baseColors.gray, opacity: 0.3 })); }); //# sourceMappingURL=Balloon.js.map