UNPKG

react-native-qrcode-mask

Version:
74 lines (62 loc) 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _reactFastCompare = _interopRequireDefault(require("react-fast-compare")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /** * Created by nghinv on Thu Jul 15 2021 * Copyright (c) 2021 nghinv@lumi.biz */ function AnimatedLine(props) { const { width, height, edgeBorderWidth, lineThick, lineSize, lineBorderRadius, lineColor, lineDirection, lineAnimationDuration } = props; const animatedValue = (0, _react.useMemo)(() => new _reactNative.Animated.Value(edgeBorderWidth), [edgeBorderWidth]); (0, _react.useEffect)(() => { const toValue = (lineDirection === 'vertical' ? height : width) - edgeBorderWidth - lineThick; const anim = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(animatedValue, { toValue, duration: lineAnimationDuration, useNativeDriver: true }), _reactNative.Animated.timing(animatedValue, { toValue: edgeBorderWidth, duration: lineAnimationDuration, useNativeDriver: true })])); anim.start(); return () => { anim.stop(); }; }, [animatedValue, width, height, lineDirection, lineAnimationDuration, edgeBorderWidth]); return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, { // @ts-ignore style: { position: 'absolute', [lineDirection === 'vertical' ? 'top' : 'left']: 0, width: lineDirection === 'vertical' ? lineSize : lineThick, height: lineDirection === 'vertical' ? lineThick : lineSize, borderRadius: lineBorderRadius, backgroundColor: lineColor, transform: [{ [lineDirection === 'vertical' ? 'translateY' : 'translateX']: animatedValue }] } }); } var _default = /*#__PURE__*/_react.default.memo(AnimatedLine, _reactFastCompare.default); exports.default = _default; //# sourceMappingURL=AnimatedLine.js.map