react-component-transition
Version:
Easy animations between react component transitions.
16 lines (15 loc) • 1.05 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.LazyTransition = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
var react_intersection_observer_1 = require("react-intersection-observer");
var transition_1 = require("./transition");
var LazyTransition = function (props) {
var animateOnMount = props.animateOnMount, animateContainer = props.animateContainer, children = props.children, disabled = props.disabled, inViewOptions = props.inViewOptions;
var _a = react_intersection_observer_1.useInView(inViewOptions), inViewRef = _a[0], inView = _a[1], entry = _a[2];
var observerWait = !entry && animateOnMount && animateContainer;
return (react_1.default.createElement(transition_1.Transition, tslib_1.__assign({}, props, { inViewRef: inViewRef, inViewEnabled: !!entry, disabled: disabled || !inView }), observerWait ? null : children));
};
exports.LazyTransition = LazyTransition;
exports.LazyTransition.displayName = "LazyTransition";
;