react-component-transition
Version:
Easy animations between react component transitions.
12 lines (11 loc) • 788 B
JavaScript
import { __assign } from "tslib";
import React from "react";
import { useInView } from "react-intersection-observer";
import { Transition } from "./transition";
export var LazyTransition = function (props) {
var animateOnMount = props.animateOnMount, animateContainer = props.animateContainer, children = props.children, disabled = props.disabled, inViewOptions = props.inViewOptions;
var _a = useInView(inViewOptions), inViewRef = _a[0], inView = _a[1], entry = _a[2];
var observerWait = !entry && animateOnMount && animateContainer;
return (React.createElement(Transition, __assign({}, props, { inViewRef: inViewRef, inViewEnabled: !!entry, disabled: disabled || !inView }), observerWait ? null : children));
};
LazyTransition.displayName = "LazyTransition";