UNPKG

primereact

Version:

PrimeReact is an open source UI library for React featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime

2 lines (1 loc) 1.57 kB
import*as e from"react";import t from"primereact/api";import{useMountEffect as r,useUpdateEffect as n,useUnmountEffect as u}from"primereact/hooks";import{DomHandler as c}from"primereact/utils";var i=e.memo(e.forwardRef((function(){var i=e.useRef(null),o=e.useRef(null),a=function(){return i.current&&i.current.parentElement},l=function(){o.current&&(o.current.addEventListener("mousedown",s),c.isTouchDevice()&&o.current.addEventListener("touchstart",p))},p=function(e){s(e),e.preventDefault()},s=function(e){if(i.current&&"none"!==getComputedStyle(i.current,null).display){if(c.removeClass(i.current,"p-ink-active"),!c.getHeight(i.current)&&!c.getWidth(i.current)){var t=Math.max(c.getOuterWidth(o.current),c.getOuterHeight(o.current));i.current.style.height=t+"px",i.current.style.width=t+"px"}var r=c.getOffset(o.current),n=e.pageX-r.left+document.body.scrollTop-c.getWidth(i.current)/2,u=e.pageY-r.top+document.body.scrollLeft-c.getHeight(i.current)/2;i.current.style.top=u+"px",i.current.style.left=n+"px",c.addClass(i.current,"p-ink-active")}};return r((function(){i.current&&(o.current=a(),l())})),n((function(){i.current&&!o.current&&(o.current=a(),l())})),u((function(){i.current&&(o.current=null,o.current&&(o.current.removeEventListener("mousedown",s),c.isTouchDevice()&&o.current.removeEventListener("touchstart",p)))})),t.ripple?e.createElement("span",{role:"presentation",ref:i,className:"p-ink",onAnimationEnd:function(e){c.removeClass(e.currentTarget,"p-ink-active")}}):null})));i.displayName="Ripple",i.defaultProps={__TYPE:"Ripple"};export{i as Ripple};