UNPKG

taos

Version:

TAOS - Tailwind CSS Animation on Scroll Library

28 lines (24 loc) 14.6 kB
var TAOS=function(J,R){"use strict";var $={exports:{}},D={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ee;function Ce(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){var b=R,h=Symbol.for("react.element"),p=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),w=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),W=Symbol.iterator,Fe="@@iterator";function De(e){if(e===null||typeof e!="object")return null;var r=W&&e[W]||e[Fe];return typeof r=="function"?r:null}var k=b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ye("error",e,t)}}function Ye(e,r,t){{var n=k.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ie=!1,Ne=!1,We=!1,Le=!1,Me=!1,ne;ne=Symbol.for("react.module.reference");function Ve(e){return!!(typeof e=="string"||typeof e=="function"||e===g||e===T||Me||e===_||e===S||e===c||Le||e===j||Ie||Ne||We||typeof e=="object"&&e!==null&&(e.$$typeof===y||e.$$typeof===m||e.$$typeof===P||e.$$typeof===w||e.$$typeof===f||e.$$typeof===ne||e.getModuleId!==void 0))}function Ue(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function ae(e){return e.displayName||"Context"}function O(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case p:return"Portal";case T:return"Profiler";case _:return"StrictMode";case S:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:var r=e;return ae(r)+".Consumer";case P:var t=e;return ae(t._context)+".Provider";case f:return Ue(e,e.render,"ForwardRef");case m:var n=e.displayName||null;return n!==null?n:O(e.type)||"Memo";case y:{var i=e,u=i._payload,o=i._init;try{return O(o(u))}catch{return null}}}return null}var x=Object.assign,I=0,oe,ie,ue,se,le,fe,ce;function de(){}de.__reactDisabledLog=!0;function Be(){{if(I===0){oe=console.log,ie=console.info,ue=console.warn,se=console.error,le=console.group,fe=console.groupCollapsed,ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:de,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}}function Je(){{if(I--,I===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:x({},e,{value:oe}),info:x({},e,{value:ie}),warn:x({},e,{value:ue}),error:x({},e,{value:se}),group:x({},e,{value:le}),groupCollapsed:x({},e,{value:fe}),groupEnd:x({},e,{value:ce})})}I<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var G=k.ReactCurrentDispatcher,z;function L(e,r,t){{if(z===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);z=n&&n[1]||""}return` `+z+e}}var H=!1,M;{var $e=typeof WeakMap=="function"?WeakMap:Map;M=new $e}function ve(e,r){if(!e||H)return"";{var t=M.get(e);if(t!==void 0)return t}var n;H=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=G.current,G.current=null,Be();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(C){n=C}Reflect.construct(e,[],o)}else{try{o.call()}catch(C){n=C}e.call(o.prototype)}}else{try{throw Error()}catch(C){n=C}e()}}catch(C){if(C&&n&&typeof C.stack=="string"){for(var a=C.stack.split(` `),v=n.stack.split(` `),s=a.length-1,l=v.length-1;s>=1&&l>=0&&a[s]!==v[l];)l--;for(;s>=1&&l>=0;s--,l--)if(a[s]!==v[l]){if(s!==1||l!==1)do if(s--,l--,l<0||a[s]!==v[l]){var E=` `+a[s].replace(" at new "," at ");return e.displayName&&E.includes("<anonymous>")&&(E=E.replace("<anonymous>",e.displayName)),typeof e=="function"&&M.set(e,E),E}while(s>=1&&l>=0);break}}}finally{H=!1,G.current=u,Je(),Error.prepareStackTrace=i}var F=e?e.displayName||e.name:"",Oe=F?L(F):"";return typeof e=="function"&&M.set(e,Oe),Oe}function Ge(e,r,t){return ve(e,!1)}function ze(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function V(e,r,t){if(e==null)return"";if(typeof e=="function")return ve(e,ze(e));if(typeof e=="string")return L(e);switch(e){case S:return L("Suspense");case c:return L("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return Ge(e.render);case m:return V(e.type,r,t);case y:{var n=e,i=n._payload,u=n._init;try{return V(u(i),r,t)}catch{}}}return""}var U=Object.prototype.hasOwnProperty,pe={},me=k.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,t=V(e.type,e._source,r?r.type:null);me.setExtraStackFrame(t)}else me.setExtraStackFrame(null)}function He(e,r,t,n,i){{var u=Function.call.bind(U);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var v=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(B(i),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),B(null)),a instanceof Error&&!(a.message in pe)&&(pe[a.message]=!0,B(i),d("Failed %s type: %s",t,a.message),B(null))}}}var Ke=Array.isArray;function K(e){return Ke(e)}function Xe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function qe(e){try{return ge(e),!1}catch{return!0}}function ge(e){return""+e}function Ee(e){if(qe(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Xe(e)),ge(e)}var N=k.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},be,he,X;X={};function Qe(e){if(U.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function er(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function rr(e,r){if(typeof e.ref=="string"&&N.current&&r&&N.current.stateNode!==r){var t=O(N.current.type);X[t]||(d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',O(N.current.type),e.ref),X[t]=!0)}}function tr(e,r){{var t=function(){be||(be=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function nr(e,r){{var t=function(){he||(he=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ar=function(e,r,t,n,i,u,o){var a={$$typeof:h,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function or(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(Ee(t),a=""+t),er(r)&&(Ee(r.key),a=""+r.key),Qe(r)&&(v=r.ref,rr(r,i));for(u in r)U.call(r,u)&&!Ze.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||v){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&tr(o,l),v&&nr(o,l)}return ar(e,a,v,i,n,N.current,o)}}var q=k.ReactCurrentOwner,ye=k.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=V(e.type,e._source,r?r.type:null);ye.setExtraStackFrame(t)}else ye.setExtraStackFrame(null)}var Z;Z=!1;function Q(e){return typeof e=="object"&&e!==null&&e.$$typeof===h}function Re(){{if(q.current){var e=O(q.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function ir(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return` Check your code at `+r+":"+t+"."}return""}}var _e={};function ur(e){{var r=Re();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` Check the top-level render call using <`+t+">.")}return r}}function Te(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ur(r);if(_e[t])return;_e[t]=!0;var n="";e&&e._owner&&e._owner!==q.current&&(n=" It was passed a child from "+O(e._owner.type)+"."),A(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function we(e,r){{if(typeof e!="object")return;if(K(e))for(var t=0;t<e.length;t++){var n=e[t];Q(n)&&Te(n,r)}else if(Q(e))e._store&&(e._store.validated=!0);else if(e){var i=De(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)Q(o.value)&&Te(o.value,r)}}}function sr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===f||r.$$typeof===m))t=r.propTypes;else return;if(t){var n=O(r);He(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!Z){Z=!0;var i=O(r);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function Se(e,r,t,n,i,u){{var o=Ve(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=ir(i);v?a+=v:a+=Re();var s;e===null?s="null":K(e)?s="array":e!==void 0&&e.$$typeof===h?(s="<"+(O(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var l=or(e,r,t,i,u);if(l==null)return l;if(o){var E=r.children;if(E!==void 0)if(n)if(K(E)){for(var F=0;F<E.length;F++)we(E[F],e);Object.freeze&&Object.freeze(E)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else we(E,e)}return e===g?lr(l):sr(l),l}}function fr(e,r,t){return Se(e,r,t,!0)}function cr(e,r,t){return Se(e,r,t,!1)}var dr=cr,vr=fr;D.Fragment=g,D.jsx=dr,D.jsxs=vr}()),D}var Y={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var re;function Pe(){if(re)return Y;re=1;var b=R,h=Symbol.for("react.element"),p=Symbol.for("react.fragment"),g=Object.prototype.hasOwnProperty,_=b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,T={key:!0,ref:!0,__self:!0,__source:!0};function P(w,f,S){var c,m={},y=null,j=null;S!==void 0&&(y=""+S),f.key!==void 0&&(y=""+f.key),f.ref!==void 0&&(j=f.ref);for(c in f)g.call(f,c)&&!T.hasOwnProperty(c)&&(m[c]=f[c]);if(w&&w.defaultProps)for(c in f=w.defaultProps,f)m[c]===void 0&&(m[c]=f[c]);return{$$typeof:h,type:w,key:y,ref:j,props:m,_owner:_.current}}return Y.Fragment=p,Y.jsx=P,Y.jsxs=P,Y}process.env.NODE_ENV==="production"?$.exports=Pe():$.exports=Ce();var je=$.exports;const xe=(b,h)=>{let p=!1;return()=>{p||(b(),p=!0,setTimeout(()=>p=!1,h))}},ke=()=>{const[b,h]=R.useState(window.scrollY);return R.useEffect(()=>{let p=!1;const g=()=>{const T=window.scrollY;h(T),p=!1},_=()=>{p||(window.requestAnimationFrame(g),p=!0)};return window.addEventListener("scroll",xe(_,25)),()=>window.removeEventListener("scroll",_)}),b},Ae=b=>b.replaceAll("taos:",""),te=({as:b="div",children:h,offset:p=0,...g})=>{const _=b,T=g.className+" taos-init",P=Ae(T),[w,f]=R.useState(g.className.replaceAll("taos:","")+" !duration-[0ms] !delay-[0ms]"),[S,c]=R.useState(null),m=R.useRef(null),y=ke(),j=W=>window.requestAnimationFrame(()=>f(W));return R.useEffect(()=>{m.current&&(window.requestAnimationFrame(()=>c(m.current.getBoundingClientRect().top-window.innerHeight+p+window.scrollY)),j(P))},[]),R.useEffect(()=>{if(S<y){j(T);return}j(P)},[S,y]),je.jsx(_,{ref:m,...g,className:w,children:h})};return te.displayName="TAOS",J.TAOS=te,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"}),J}({},React);