UNPKG

react-native-video-player

Version:
44 lines (43 loc) 1.29 kB
"use strict"; import { forwardRef, memo, useCallback, useImperativeHandle, useRef } from 'react'; import { Animated, StyleSheet } from 'react-native'; import { jsx as _jsx } from "react/jsx-runtime"; export const AnimatedWrapper = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(({ animationDuration, children, customStylesControls }, ref) => { const animationValue = useRef(new Animated.Value(0)).current; const runControlsAnimation = useCallback((toValue, callback) => { Animated.timing(animationValue, { toValue, duration: animationDuration, useNativeDriver: true }).start(callback); }, [animationDuration, animationValue]); useImperativeHandle(ref, () => ({ runControlsAnimation })); const controlsTranslateY = animationValue.interpolate({ inputRange: [0, 1], outputRange: [48, 0] }); return /*#__PURE__*/_jsx(Animated.View, { style: [styles.controls, customStylesControls, { transform: [{ translateY: controlsTranslateY }] }], children: children }); })); const styles = StyleSheet.create({ controls: { backgroundColor: 'rgba(0, 0, 0, 0.6)', height: 48, marginTop: -48, flexDirection: 'row', alignItems: 'center' } }); //# sourceMappingURL=ControlsAnimatedWrapper.js.map