@chief-editor/ui
Version:
UI Component for chief editor
1 lines • 1.69 kB
JavaScript
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},TransformType={"top-left":function(t){return"translate3d("+100*(t-1)+"%,0,0)"},"top-right":function(t){return"translate3d("+100*(1-t)+"%,0,0)"},"top-center":function(t){return"translate3d(0,"+48*(t-1)+"px,0)"},"bottom-left":function(t,e,r){return"translate3d("+100*(t-1)+"%,"+(t-1)*(e+r)+"px,0)"},"bottom-right":function(t,e,r){return"translate3d("+100*(1-t)+"%,"+(t-1)*(e+r)+"px,0)"},"bottom-center":function(t){return"translate3d(0,"+48*(1-t)+"px,0)"}};export function getAnimationConfig(t,e){var r=function(r,n){return{opacity:r,height:n*r+"px",marginBottom:t*r+"px",transform:TransformType[e](r,n,t)}};return{duration:200,childRefKey:"wrapperRef",enterChildProps:function(t){return{style:__assign(__assign({},r(0,144)),t.style)}},enterTick:function(t,e,n){if(e>=1)return removeStyleProperties(t,"height","opacity","transform"),n;var o=t.firstElementChild,i=n||(null==o?void 0:o.getBoundingClientRect().height);return i&&setStyleProperties(t,r(e,i)),i},leaveTick:function(t,e,n){if(e>=1)return n;var o=n||t.getBoundingClientRect().height;return o&&setStyleProperties(t,r(1-e,o)),o}}}function removeStyleProperties(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];e.forEach((function(e){return t.style.removeProperty(getStyleKey(e))}))}function setStyleProperties(t,e){Object.keys(e).forEach((function(r){return t.style.setProperty(getStyleKey(r),""+e[r])}))}function getStyleKey(t){return t.replace(/(?=[A-Z])/g,"-").toLowerCase()}