UNPKG

taos

Version:

TAOS - Tailwind CSS Animation on Scroll Library

28 lines (24 loc) 14.6 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react");var Z={exports:{}},I={};/** * @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 we;function ur(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){var b=C,h=Symbol.for("react.element"),p=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),w=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),T=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"),$=Symbol.iterator,Oe="@@iterator";function Ce(e){if(e===null||typeof e!="object")return null;var r=$&&e[$]||e[Oe];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];Pe("error",e,t)}}function Pe(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 je=!1,xe=!1,ke=!1,Ae=!1,Fe=!1,Q;Q=Symbol.for("react.module.reference");function De(e){return!!(typeof e=="string"||typeof e=="function"||e===g||e===_||Fe||e===R||e===T||e===c||Ae||e===j||je||xe||ke||typeof e=="object"&&e!==null&&(e.$$typeof===y||e.$$typeof===m||e.$$typeof===P||e.$$typeof===w||e.$$typeof===f||e.$$typeof===Q||e.getModuleId!==void 0))}function Ye(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function ee(e){return e.displayName||"Context"}function S(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 _:return"Profiler";case R:return"StrictMode";case T:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:var r=e;return ee(r)+".Consumer";case P:var t=e;return ee(t._context)+".Provider";case f:return Ye(e,e.render,"ForwardRef");case m:var n=e.displayName||null;return n!==null?n:S(e.type)||"Memo";case y:{var i=e,u=i._payload,o=i._init;try{return S(o(u))}catch{return null}}}return null}var x=Object.assign,D=0,re,te,ne,ae,oe,ie,ue;function se(){}se.__reactDisabledLog=!0;function Ie(){{if(D===0){re=console.log,te=console.info,ne=console.warn,ae=console.error,oe=console.group,ie=console.groupCollapsed,ue=console.groupEnd;var e={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}D++}}function Ne(){{if(D--,D===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:x({},e,{value:re}),info:x({},e,{value:te}),warn:x({},e,{value:ne}),error:x({},e,{value:ae}),group:x({},e,{value:oe}),groupCollapsed:x({},e,{value:ie}),groupEnd:x({},e,{value:ue})})}D<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=k.ReactCurrentDispatcher,B;function W(e,r,t){{if(B===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);B=n&&n[1]||""}return` `+B+e}}var J=!1,L;{var $e=typeof WeakMap=="function"?WeakMap:Map;L=new $e}function le(e,r){if(!e||J)return"";{var t=L.get(e);if(t!==void 0)return t}var n;J=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Ie();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(O){n=O}Reflect.construct(e,[],o)}else{try{o.call()}catch(O){n=O}e.call(o.prototype)}}else{try{throw Error()}catch(O){n=O}e()}}catch(O){if(O&&n&&typeof O.stack=="string"){for(var a=O.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"&&L.set(e,E),E}while(s>=1&&l>=0);break}}}finally{J=!1,q.current=u,Ne(),Error.prepareStackTrace=i}var F=e?e.displayName||e.name:"",_e=F?W(F):"";return typeof e=="function"&&L.set(e,_e),_e}function We(e,r,t){return le(e,!1)}function Le(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function M(e,r,t){if(e==null)return"";if(typeof e=="function")return le(e,Le(e));if(typeof e=="string")return W(e);switch(e){case T:return W("Suspense");case c:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return We(e.render);case m:return M(e.type,r,t);case y:{var n=e,i=n._payload,u=n._init;try{return M(u(i),r,t)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,fe={},ce=k.ReactDebugCurrentFrame;function U(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);ce.setExtraStackFrame(t)}else ce.setExtraStackFrame(null)}function Me(e,r,t,n,i){{var u=Function.call.bind(V);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)&&(U(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),U(null)),a instanceof Error&&!(a.message in fe)&&(fe[a.message]=!0,U(i),d("Failed %s type: %s",t,a.message),U(null))}}}var Ve=Array.isArray;function G(e){return Ve(e)}function Ue(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function qe(e){try{return de(e),!1}catch{return!0}}function de(e){return""+e}function ve(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.",Ue(e)),de(e)}var Y=k.ReactCurrentOwner,Be={key:!0,ref:!0,__self:!0,__source:!0},pe,me,z;z={};function Je(e){if(V.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ge(e){if(V.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ze(e,r){if(typeof e.ref=="string"&&Y.current&&r&&Y.current.stateNode!==r){var t=S(Y.current.type);z[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',S(Y.current.type),e.ref),z[t]=!0)}}function He(e,r){{var t=function(){pe||(pe=!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 Ke(e,r){{var t=function(){me||(me=!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 Xe=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 Ze(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(ve(t),a=""+t),Ge(r)&&(ve(r.key),a=""+r.key),Je(r)&&(v=r.ref,ze(r,i));for(u in r)V.call(r,u)&&!Be.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&&He(o,l),v&&Ke(o,l)}return Xe(e,a,v,i,n,Y.current,o)}}var H=k.ReactCurrentOwner,ge=k.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);ge.setExtraStackFrame(t)}else ge.setExtraStackFrame(null)}var K;K=!1;function X(e){return typeof e=="object"&&e!==null&&e.$$typeof===h}function Ee(){{if(H.current){var e=S(H.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function Qe(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return` Check your code at `+r+":"+t+"."}return""}}var be={};function er(e){{var r=Ee();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 he(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=er(r);if(be[t])return;be[t]=!0;var n="";e&&e._owner&&e._owner!==H.current&&(n=" It was passed a child from "+S(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 ye(e,r){{if(typeof e!="object")return;if(G(e))for(var t=0;t<e.length;t++){var n=e[t];X(n)&&he(n,r)}else if(X(e))e._store&&(e._store.validated=!0);else if(e){var i=Ce(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)X(o.value)&&he(o.value,r)}}}function rr(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=S(r);Me(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!K){K=!0;var i=S(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 tr(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 Re(e,r,t,n,i,u){{var o=De(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=Qe(i);v?a+=v:a+=Ee();var s;e===null?s="null":G(e)?s="array":e!==void 0&&e.$$typeof===h?(s="<"+(S(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=Ze(e,r,t,i,u);if(l==null)return l;if(o){var E=r.children;if(E!==void 0)if(n)if(G(E)){for(var F=0;F<E.length;F++)ye(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 ye(E,e)}return e===g?tr(l):rr(l),l}}function nr(e,r,t){return Re(e,r,t,!0)}function ar(e,r,t){return Re(e,r,t,!1)}var or=ar,ir=nr;I.Fragment=g,I.jsx=or,I.jsxs=ir}()),I}var N={};/** * @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 Te;function sr(){if(Te)return N;Te=1;var b=C,h=Symbol.for("react.element"),p=Symbol.for("react.fragment"),g=Object.prototype.hasOwnProperty,R=b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function P(w,f,T){var c,m={},y=null,j=null;T!==void 0&&(y=""+T),f.key!==void 0&&(y=""+f.key),f.ref!==void 0&&(j=f.ref);for(c in f)g.call(f,c)&&!_.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:R.current}}return N.Fragment=p,N.jsx=P,N.jsxs=P,N}process.env.NODE_ENV==="production"?Z.exports=sr():Z.exports=ur();var lr=Z.exports;const fr=(b,h)=>{let p=!1;return()=>{p||(b(),p=!0,setTimeout(()=>p=!1,h))}},cr=()=>{const[b,h]=C.useState(window.scrollY);return C.useEffect(()=>{let p=!1;const g=()=>{const _=window.scrollY;h(_),p=!1},R=()=>{p||(window.requestAnimationFrame(g),p=!0)};return window.addEventListener("scroll",fr(R,25)),()=>window.removeEventListener("scroll",R)}),b},dr=b=>b.replaceAll("taos:",""),Se=({as:b="div",children:h,offset:p=0,...g})=>{const R=b,_=g.className+" taos-init",P=dr(_),[w,f]=C.useState(g.className.replaceAll("taos:","")+" !duration-[0ms] !delay-[0ms]"),[T,c]=C.useState(null),m=C.useRef(null),y=cr(),j=$=>window.requestAnimationFrame(()=>f($));return C.useEffect(()=>{m.current&&(window.requestAnimationFrame(()=>c(m.current.getBoundingClientRect().top-window.innerHeight+p+window.scrollY)),j(P))},[]),C.useEffect(()=>{if(T<y){j(_);return}j(P)},[T,y]),lr.jsx(R,{ref:m,...g,className:w,children:h})};Se.displayName="TAOS";exports.TAOS=Se;