UNPKG

@progress/kendo-react-animation

Version:

React Animation component assists with animating HTML elements. KendoReact Animation package

9 lines (8 loc) 2.25 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),i=require("prop-types"),F=require("./Animation.js"),x=require("./util.js");function N(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const s=N(w),h=e=>{const[r,o]=s.useState(),[a,p]=s.useState(),[u,E]=s.useState({}),{appear:y=l.appear,enter:v=l.enter,exit:W=l.exit,transitionEnterDuration:O=l.transitionEnterDuration,transitionExitDuration:D=l.transitionExitDuration,direction:f=l.direction,children:H,childFactory:g,...T}=e;let c;f==="vertical"?c={maxHeight:r?`${r}px`:""}:c={maxWidth:a?`${a}px`:""};const b={maxHeight:c.maxHeight,maxWidth:c.maxWidth};s.useEffect(()=>{e&&u.name&&e[u.name]&&e[u.name].call(void 0,u.event)},[r,a,u]);const S=t=>{const{onBeforeEnter:n}=e;n&&n.call(void 0,t),m(t,"onEnter")},j=t=>{m(t,"onEntering")},P=t=>{m(t,"onExit")},m=(t,n)=>{const d=t.animatedElement.firstChild;if(d){const M=x.outerHeight(d),R=x.outerWidth(d);o(M),p(R),E({name:n,event:t})}},q=t=>{const n=g?g(t):t;return n.props.in?n:s.cloneElement(n,{...n.props,style:{...n.props.style,maxHeight:c.maxHeight,maxWidth:c.maxWidth}})};return s.createElement(F.Animation,{...T,appear:y,enter:v,exit:W,transitionEnterDuration:O,transitionExitDuration:D,childFactory:q,onEnter:S,onEntering:j,onExit:P,animationEnteringStyle:b,transitionName:`reveal-${f}`},H)},l={appear:!1,enter:!0,exit:!0,transitionEnterDuration:300,transitionExitDuration:300,direction:"vertical"};h.propTypes={children:i.oneOfType([i.arrayOf(i.node),i.node]),childFactory:i.any,className:i.string,direction:i.oneOf(["horizontal","vertical"]),component:i.string,id:i.string,style:i.any};exports.Reveal=h;