UNPKG

@kirz/react-native-toolkit

Version:

Toolkit to speed up React Native development

39 lines 1.48 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); } import { BlurView as BlurViewBase } from '@kirz/react-native-blur'; import React, { useEffect, useRef, useState } from 'react'; import { Animated } from 'react-native'; export function BlurView(_ref) { let { animated, enteringAnimationDuration = 200, blurAmount = 10, ...props } = _ref; const enteringAnimation = useRef(new Animated.Value(0)).current; const [animatedBlurAmount, setAnimatedBlurAmount] = useState(0); useEffect(() => { if (!animated) { return; } const animation = Animated.timing(enteringAnimation, { toValue: blurAmount, duration: enteringAnimationDuration, useNativeDriver: false }); animation.start(); const listener = enteringAnimation.addListener(_ref2 => { let { value } = _ref2; setAnimatedBlurAmount(value); }); return () => { animation.stop(); enteringAnimation.removeListener(listener); }; }, [animated]); return /*#__PURE__*/React.createElement(BlurViewBase, _extends({ blurAmount: animated ? animatedBlurAmount : blurAmount }, props)); } //# sourceMappingURL=BlurView.js.map