react-native-fiesta
Version:
A set of celebration animations powered by Skia. Engage more with your users by celebrating in your React Native application.
38 lines (37 loc) • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Star = 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 Star = exports.Star = /*#__PURE__*/(0, _react.memo)(({
x,
y,
autoplay = true,
color = _theming.baseColors.yellow
}) => {
const opacity = (0, _reactNativeReanimated.useSharedValue)(1);
const matrix = (0, _react.useMemo)(() => (0, _reactNativeSkia.processTransform2d)([{
translateX: x
}, {
translateY: y
}, {
scale: 0.1
}]), [x, y]);
(0, _react.useEffect)(() => {
opacity.value = (0, _reactNativeReanimated.withSpring)(autoplay ? 0 : 1, _speed.singleItemFadeSpeed);
}, [autoplay, opacity]);
return /*#__PURE__*/_react.default.createElement(_reactNativeSkia.Path, {
path: "M 128 0 L 168 80 L 256 93 L 192 155 L 207 244 L 128 202 L 49 244 L 64 155 L 0 93 L 88 80 L 128 0 Z",
color: color,
opacity: opacity,
matrix: matrix
});
});
//# sourceMappingURL=Star.js.map