@react-scrollytelling/react-spring 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `core`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const core = require('core');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),d=require("@react-spring/web");function f(){if(typeof window=="undefined")return{scrollTop:0,scrollBottom:0,windowHeight:10};const e=window.scrollY||document.documentElement.scrollTop,n=window.innerHeight||document.documentElement.clientHeight,o=e+n;return{scrollTop:e,scrollBottom:o,windowHeight:n}}function g(e){return e<0?0:e>1?1:e}const w={};function m(e,n=w,o=!0,t){const[l,s]=i.useState(!1),c=i.useRef(null),r=i.useCallback(()=>{c.current&&c.current.disconnect()},[]);return i.useEffect(()=>{if(window&&IntersectionObserver&&o){c.current=new IntersectionObserver(([a])=>{s(a.isIntersecting),t&&t(a,r)},n);const u=e.current;return u&&c.current.observe(e.current),()=>{c.current&&u&&c.current.unobserve(u)}}},[e,n,o,t]),{isIntersecting:l,disconnect:r}}function b(e){const n=i.useRef(null),o=i.useCallback((...t)=>{e(...t),n.current=null},[e]);return i.useEffect(()=>()=>{n.current&&cancelAnimationFrame(n.current)},[]),i.useCallback((...t)=>{const l=()=>o(...t);n.current||(n.current=requestAnimationFrame(l))},[o])}function S(e,n){var o;const t=(o=e.current)==null?void 0:o.getBoundingClientRect();if(!t)return{scrolledRatio:0,scrollBottom:0,distance:1/0,isIntersecting:n};const{scrollTop:l,scrollBottom:s}=f(),c=t.top+l,r=s-c;return{scrolledRatio:g(r/t.height),scrollBottom:s,distance:r,isIntersecting:n}}function p(e,n,o=!0,t){const l=i.useCallback(r=>{const u=S(e,r);n(u)},[e,n]),s=b(l),c=i.useCallback(({isIntersecting:r})=>{s(r),r?window.addEventListener("scroll",s.bind(null,r)):window.removeEventListener("scroll",s.bind(null,r))},[s]);m(e,t,o,c)}function v(e,n,o=!0,t){const l=i.useRef(new d.SpringValue(0)),s=i.useCallback(c=>{const{scrolledRatio:r}=c;console.log("onSectionScroll",r),l.current.set(r),n&&n(c)},[n]);return p(e,s,o,t),{scrolledRatioSpring:l.current}}exports.useSectionScrollSpring=v;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../core/dist/index.es.js","../src/hooks/useSectionScrollSpring.ts"],"sourcesContent":["import { useState as a, useRef as d, useCallback as u, useEffect as g } from \"react\";\nfunction w() {\n if (typeof window == \"undefined\")\n return {\n scrollTop: 0,\n scrollBottom: 0,\n windowHeight: 10\n };\n const t = window.scrollY || document.documentElement.scrollTop, n = window.innerHeight || document.documentElement.clientHeight, e = t + n;\n return {\n scrollTop: t,\n scrollBottom: e,\n windowHeight: n\n };\n}\nfunction S(t) {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\nconst m = {};\nfunction I(t, n = m, e = !0, r) {\n const [s, i] = a(!1), o = d(null), c = u(() => {\n o.current && o.current.disconnect();\n }, []);\n return g(() => {\n if (window && IntersectionObserver && e) {\n o.current = new IntersectionObserver(([f]) => {\n i(f.isIntersecting), r && r(f, c);\n }, n);\n const l = t.current;\n return l && o.current.observe(t.current), () => {\n o.current && l && o.current.unobserve(l);\n };\n }\n }, [t, n, e, r]), { isIntersecting: s, disconnect: c };\n}\nfunction R(t, n, e) {\n const [r, s] = a(!1), i = u((c) => {\n s(c.isIntersecting);\n }, []), { disconnect: o } = I(t, n, e, i);\n return { isIntersecting: r, disconnect: o };\n}\nfunction E(t, n = !1, e = m) {\n const r = d(!1), [s, i] = a(!1), o = u(\n (c, l) => {\n const f = c.isIntersecting;\n i(f), n && !r.current && f && l();\n },\n [n]\n );\n return I(t, e, !0, o), { isIntersecting: s };\n}\nfunction v(t) {\n const n = d(null), e = u(\n (...r) => {\n t(...r), n.current = null;\n },\n [t]\n );\n return g(() => () => {\n n.current && cancelAnimationFrame(n.current);\n }, []), u(\n (...r) => {\n const s = () => e(...r);\n n.current || (n.current = requestAnimationFrame(s));\n },\n [e]\n );\n}\nfunction T(t, n) {\n var l;\n const e = (l = t.current) == null ? void 0 : l.getBoundingClientRect();\n if (!e)\n return { scrolledRatio: 0, scrollBottom: 0, distance: 1 / 0, isIntersecting: n };\n const { scrollTop: r, scrollBottom: s } = w(), i = e.top + r, o = s - i;\n return { scrolledRatio: S(o / e.height), scrollBottom: s, distance: o, isIntersecting: n };\n}\nfunction b(t, n, e = !0, r) {\n const s = u(\n (c) => {\n const l = T(t, c);\n n(l);\n },\n [t, n]\n ), i = v(s), o = u(\n ({ isIntersecting: c }) => {\n i(c), c ? window.addEventListener(\"scroll\", i.bind(null, c)) : window.removeEventListener(\"scroll\", i.bind(null, c));\n },\n [i]\n );\n I(t, r, e, o);\n}\nfunction h(t, n = !0, e) {\n const [r, s] = a(0), [i, o] = a(!1), c = u(\n ({ scrolledRatio: l, isIntersecting: f }) => {\n s(l), o(f);\n },\n []\n );\n return b(t, c, n, e), { scrolledRatio: r, isIntersecting: i };\n}\nexport {\n m as DEFAULT_INTERSECTION_OBS_OPTIONS,\n S as clampScrolledRatio,\n w as getScrollPosition,\n T as getSectionScrollInfo,\n I as useIntersectionObserver,\n R as useIntersectionObserverState,\n E as useIntersectionReveal,\n v as useRafThrottle,\n b as useSectionScroll,\n h as useSectionScrollState\n};\n//# sourceMappingURL=index.es.js.map\n","import { useCallback, useRef } from 'react';\n\nimport {\n IntersectionObserverOptions,\n SectionScrollInfo,\n useSectionScroll,\n} from '@react-scrollytelling/core';\nimport { SpringValue } from '@react-spring/web';\n\n/**\n * Get the state of the section scroll\n * @param sectionRef - The reference to the section element\n * @param shouldObserve - Whether the underlying IntersectionObserver should be active\n * @param onScroll - The callback to track the scroll ratio\n */\nexport function useSectionScrollSpring(\n sectionRef: React.RefObject<Element>,\n onScroll?: (scrollInfo: SectionScrollInfo) => void,\n shouldObserve = true,\n options?: IntersectionObserverOptions\n) {\n const scrolledRatioSpringRef = useRef(new SpringValue(0));\n\n const onSectionScroll = useCallback(\n (scrollInfo: SectionScrollInfo) => {\n const { scrolledRatio } = scrollInfo;\n console.log('onSectionScroll', scrolledRatio);\n scrolledRatioSpringRef.current.set(scrolledRatio);\n\n if (onScroll) {\n onScroll(scrollInfo);\n }\n },\n [onScroll]\n );\n\n useSectionScroll(sectionRef, onSectionScroll, shouldObserve, options);\n\n return { scrolledRatioSpring: scrolledRatioSpringRef.current };\n}\n"],"names":["w","t","e","S","m","I","r","s","i","a","o","d","c","u","g","f","l","v","T","b","useSectionScrollSpring","sectionRef","onScroll","shouldObserve","options","scrolledRatioSpringRef","useRef","SpringValue","onSectionScroll","useCallback","scrollInfo","scrolledRatio","useSectionScroll"],"mappings":"wIACA,SAASA,GAAI,CACX,GAAI,OAAO,QAAU,YACnB,MAAO,CACL,UAAW,EACX,aAAc,EACd,aAAc,EACpB,EACE,MAAMC,EAAI,OAAO,SAAW,SAAS,gBAAgB,UAAW,EAAI,OAAO,aAAe,SAAS,gBAAgB,aAAcC,EAAID,EAAI,EACzI,MAAO,CACL,UAAWA,EACX,aAAcC,EACd,aAAc,CAClB,CACA,CACA,SAASC,EAAEF,EAAG,CACZ,OAAOA,EAAI,EAAI,EAAIA,EAAI,EAAI,EAAIA,CACjC,CACA,MAAMG,EAAI,CAAA,EACV,SAASC,EAAEJ,EAAG,EAAIG,EAAGF,EAAI,GAAII,EAAG,CAC9B,KAAM,CAACC,EAAGC,CAAC,EAAIC,EAAAA,SAAE,EAAE,EAAGC,EAAIC,EAAC,OAAC,IAAI,EAAGC,EAAIC,EAAC,YAAC,IAAM,CAC7CH,EAAE,SAAWA,EAAE,QAAQ,WAAU,CAClC,EAAE,CAAE,CAAA,EACL,OAAOI,EAAC,UAAC,IAAM,CACb,GAAI,QAAU,sBAAwBZ,EAAG,CACvCQ,EAAE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C,EAAI,GAAII,EAAG,CAC1B,MAAMC,EAAIM,EAAC,YACRD,GAAM,CACL,MAAMI,EAAIE,EAAEjB,EAAGW,CAAC,EAChB,EAAEI,CAAC,CACJ,EACD,CAACf,EAAG,CAAC,CACN,EAAEO,EAAIS,EAAEV,CAAC,EAAGG,EAAIG,EAAC,YAChB,CAAC,CAAE,eAAgBD,KAAQ,CACzBJ,EAAEI,CAAC,EAAGA,EAAI,OAAO,iBAAiB,SAAUJ,EAAE,KAAK,KAAMI,CAAC,CAAC,EAAI,OAAO,oBAAoB,SAAUJ,EAAE,KAAK,KAAMI,CAAC,CAAC,CACpH,EACD,CAACJ,CAAC,CACN,EACEH,EAAEJ,EAAGK,EAAGJ,EAAGQ,CAAC,CACd,CC3EO,SAASU,EACdC,EACAC,EACAC,EAAgB,GAChBC,EACA,CACA,MAAMC,EAAyBC,EAAA,OAAO,IAAIC,EAAAA,YAAY,CAAC,CAAC,EAElDC,EAAkBC,EAAA,YACrBC,GAAkC,CAC3B,KAAA,CAAE,cAAAC,CAAkB,EAAAD,EAClB,QAAA,IAAI,kBAAmBC,CAAa,EACrBN,EAAA,QAAQ,IAAIM,CAAa,EAE5CT,GACFA,EAASQ,CAAU,CAEvB,EACA,CAACR,CAAQ,CAAA,EAGMU,OAAAA,EAAAX,EAAYO,EAAiBL,EAAeC,CAAO,EAE7D,CAAE,oBAAqBC,EAAuB,QACvD"}
@@ -0,0 +1,90 @@
1
+ import { useCallback as l, useState as a, useRef as d, useEffect as w } from "react";
2
+ import { SpringValue as f } from "@react-spring/web";
3
+ function g() {
4
+ if (typeof window == "undefined")
5
+ return {
6
+ scrollTop: 0,
7
+ scrollBottom: 0,
8
+ windowHeight: 10
9
+ };
10
+ const n = window.scrollY || document.documentElement.scrollTop, e = window.innerHeight || document.documentElement.clientHeight, o = n + e;
11
+ return {
12
+ scrollTop: n,
13
+ scrollBottom: o,
14
+ windowHeight: e
15
+ };
16
+ }
17
+ function p(n) {
18
+ return n < 0 ? 0 : n > 1 ? 1 : n;
19
+ }
20
+ const v = {};
21
+ function S(n, e = v, o = !0, t) {
22
+ const [s, i] = a(!1), c = d(null), r = l(() => {
23
+ c.current && c.current.disconnect();
24
+ }, []);
25
+ return w(() => {
26
+ if (window && IntersectionObserver && o) {
27
+ c.current = new IntersectionObserver(([m]) => {
28
+ i(m.isIntersecting), t && t(m, r);
29
+ }, e);
30
+ const u = n.current;
31
+ return u && c.current.observe(n.current), () => {
32
+ c.current && u && c.current.unobserve(u);
33
+ };
34
+ }
35
+ }, [n, e, o, t]), { isIntersecting: s, disconnect: r };
36
+ }
37
+ function b(n) {
38
+ const e = d(null), o = l(
39
+ (...t) => {
40
+ n(...t), e.current = null;
41
+ },
42
+ [n]
43
+ );
44
+ return w(() => () => {
45
+ e.current && cancelAnimationFrame(e.current);
46
+ }, []), l(
47
+ (...t) => {
48
+ const s = () => o(...t);
49
+ e.current || (e.current = requestAnimationFrame(s));
50
+ },
51
+ [o]
52
+ );
53
+ }
54
+ function R(n, e) {
55
+ var o;
56
+ const t = (o = n.current) == null ? void 0 : o.getBoundingClientRect();
57
+ if (!t)
58
+ return { scrolledRatio: 0, scrollBottom: 0, distance: 1 / 0, isIntersecting: e };
59
+ const { scrollTop: s, scrollBottom: i } = g(), c = t.top + s, r = i - c;
60
+ return { scrolledRatio: p(r / t.height), scrollBottom: i, distance: r, isIntersecting: e };
61
+ }
62
+ function I(n, e, o = !0, t) {
63
+ const s = l(
64
+ (r) => {
65
+ const u = R(n, r);
66
+ e(u);
67
+ },
68
+ [n, e]
69
+ ), i = b(s), c = l(
70
+ ({ isIntersecting: r }) => {
71
+ i(r), r ? window.addEventListener("scroll", i.bind(null, r)) : window.removeEventListener("scroll", i.bind(null, r));
72
+ },
73
+ [i]
74
+ );
75
+ S(n, t, o, c);
76
+ }
77
+ function E(n, e, o = !0, t) {
78
+ const s = d(new f(0)), i = l(
79
+ (c) => {
80
+ const { scrolledRatio: r } = c;
81
+ console.log("onSectionScroll", r), s.current.set(r), e && e(c);
82
+ },
83
+ [e]
84
+ );
85
+ return I(n, i, o, t), { scrolledRatioSpring: s.current };
86
+ }
87
+ export {
88
+ E as useSectionScrollSpring
89
+ };
90
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../core/dist/index.es.js","../src/hooks/useSectionScrollSpring.ts"],"sourcesContent":["import { useState as a, useRef as d, useCallback as u, useEffect as g } from \"react\";\nfunction w() {\n if (typeof window == \"undefined\")\n return {\n scrollTop: 0,\n scrollBottom: 0,\n windowHeight: 10\n };\n const t = window.scrollY || document.documentElement.scrollTop, n = window.innerHeight || document.documentElement.clientHeight, e = t + n;\n return {\n scrollTop: t,\n scrollBottom: e,\n windowHeight: n\n };\n}\nfunction S(t) {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\nconst m = {};\nfunction I(t, n = m, e = !0, r) {\n const [s, i] = a(!1), o = d(null), c = u(() => {\n o.current && o.current.disconnect();\n }, []);\n return g(() => {\n if (window && IntersectionObserver && e) {\n o.current = new IntersectionObserver(([f]) => {\n i(f.isIntersecting), r && r(f, c);\n }, n);\n const l = t.current;\n return l && o.current.observe(t.current), () => {\n o.current && l && o.current.unobserve(l);\n };\n }\n }, [t, n, e, r]), { isIntersecting: s, disconnect: c };\n}\nfunction R(t, n, e) {\n const [r, s] = a(!1), i = u((c) => {\n s(c.isIntersecting);\n }, []), { disconnect: o } = I(t, n, e, i);\n return { isIntersecting: r, disconnect: o };\n}\nfunction E(t, n = !1, e = m) {\n const r = d(!1), [s, i] = a(!1), o = u(\n (c, l) => {\n const f = c.isIntersecting;\n i(f), n && !r.current && f && l();\n },\n [n]\n );\n return I(t, e, !0, o), { isIntersecting: s };\n}\nfunction v(t) {\n const n = d(null), e = u(\n (...r) => {\n t(...r), n.current = null;\n },\n [t]\n );\n return g(() => () => {\n n.current && cancelAnimationFrame(n.current);\n }, []), u(\n (...r) => {\n const s = () => e(...r);\n n.current || (n.current = requestAnimationFrame(s));\n },\n [e]\n );\n}\nfunction T(t, n) {\n var l;\n const e = (l = t.current) == null ? void 0 : l.getBoundingClientRect();\n if (!e)\n return { scrolledRatio: 0, scrollBottom: 0, distance: 1 / 0, isIntersecting: n };\n const { scrollTop: r, scrollBottom: s } = w(), i = e.top + r, o = s - i;\n return { scrolledRatio: S(o / e.height), scrollBottom: s, distance: o, isIntersecting: n };\n}\nfunction b(t, n, e = !0, r) {\n const s = u(\n (c) => {\n const l = T(t, c);\n n(l);\n },\n [t, n]\n ), i = v(s), o = u(\n ({ isIntersecting: c }) => {\n i(c), c ? window.addEventListener(\"scroll\", i.bind(null, c)) : window.removeEventListener(\"scroll\", i.bind(null, c));\n },\n [i]\n );\n I(t, r, e, o);\n}\nfunction h(t, n = !0, e) {\n const [r, s] = a(0), [i, o] = a(!1), c = u(\n ({ scrolledRatio: l, isIntersecting: f }) => {\n s(l), o(f);\n },\n []\n );\n return b(t, c, n, e), { scrolledRatio: r, isIntersecting: i };\n}\nexport {\n m as DEFAULT_INTERSECTION_OBS_OPTIONS,\n S as clampScrolledRatio,\n w as getScrollPosition,\n T as getSectionScrollInfo,\n I as useIntersectionObserver,\n R as useIntersectionObserverState,\n E as useIntersectionReveal,\n v as useRafThrottle,\n b as useSectionScroll,\n h as useSectionScrollState\n};\n//# sourceMappingURL=index.es.js.map\n","import { useCallback, useRef } from 'react';\n\nimport {\n IntersectionObserverOptions,\n SectionScrollInfo,\n useSectionScroll,\n} from '@react-scrollytelling/core';\nimport { SpringValue } from '@react-spring/web';\n\n/**\n * Get the state of the section scroll\n * @param sectionRef - The reference to the section element\n * @param shouldObserve - Whether the underlying IntersectionObserver should be active\n * @param onScroll - The callback to track the scroll ratio\n */\nexport function useSectionScrollSpring(\n sectionRef: React.RefObject<Element>,\n onScroll?: (scrollInfo: SectionScrollInfo) => void,\n shouldObserve = true,\n options?: IntersectionObserverOptions\n) {\n const scrolledRatioSpringRef = useRef(new SpringValue(0));\n\n const onSectionScroll = useCallback(\n (scrollInfo: SectionScrollInfo) => {\n const { scrolledRatio } = scrollInfo;\n console.log('onSectionScroll', scrolledRatio);\n scrolledRatioSpringRef.current.set(scrolledRatio);\n\n if (onScroll) {\n onScroll(scrollInfo);\n }\n },\n [onScroll]\n );\n\n useSectionScroll(sectionRef, onSectionScroll, shouldObserve, options);\n\n return { scrolledRatioSpring: scrolledRatioSpringRef.current };\n}\n"],"names":["w","t","n","e","S","m","I","r","a","o","d","c","u","g","f","l","v","T","s","i","b","useSectionScrollSpring","sectionRef","onScroll","shouldObserve","options","scrolledRatioSpringRef","useRef","SpringValue","onSectionScroll","useCallback","scrollInfo","scrolledRatio","useSectionScroll"],"mappings":";;AACA,SAASA,IAAI;AACX,MAAI,OAAO,UAAU;AACnB,WAAO;AAAA,MACL,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,IACpB;AACE,QAAMC,IAAI,OAAO,WAAW,SAAS,gBAAgB,WAAWC,IAAI,OAAO,eAAe,SAAS,gBAAgB,cAAcC,IAAIF,IAAIC;AACzI,SAAO;AAAA,IACL,WAAWD;AAAA,IACX,cAAcE;AAAA,IACd,cAAcD;AAAA,EAClB;AACA;AACA,SAASE,EAAEH,GAAG;AACZ,SAAOA,IAAI,IAAI,IAAIA,IAAI,IAAI,IAAIA;AACjC;AACA,MAAMI,IAAI,CAAA;AACV,SAASC,EAAEL,GAAGC,IAAIG,GAAGF,IAAI,IAAII,GAAG;AAC9B,QAAM,CAAC,GAAG,CAAC,IAAIC,EAAE,EAAE,GAAGC,IAAIC,EAAE,IAAI,GAAGC,IAAIC,EAAE,MAAM;AAC7C,IAAAH,EAAE,WAAWA,EAAE,QAAQ,WAAU;AAAA,EAClC,GAAE,CAAE,CAAA;AACL,SAAOI,EAAE,MAAM;AACb,QAAI,UAAU,wBAAwBV,GAAG;AACvC,MAAAM,EAAE,UAAU,IAAI,qBAAqB,CAAC,CAACK,CAAC,MAAM;AAC5C,UAAEA,EAAE,cAAc,GAAGP,KAAKA,EAAEO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GAAGC,IAAI,IAAII,GAAG;AAC1B,QAAM,IAAIK;AAAAA,IACR,CAACD,MAAM;AACL,YAAMI,IAAIE,EAAEhB,GAAGU,CAAC;AAChB,MAAAT,EAAEa,CAAC;AAAA,IACJ;AAAA,IACD,CAACd,GAAGC,CAAC;AAAA,EACN,GAAE,IAAIc,EAAE,CAAC,GAAGP,IAAIG;AAAAA,IACf,CAAC,EAAE,gBAAgBD,QAAQ;AACzB,QAAEA,CAAC,GAAGA,IAAI,OAAO,iBAAiB,UAAU,EAAE,KAAK,MAAMA,CAAC,CAAC,IAAI,OAAO,oBAAoB,UAAU,EAAE,KAAK,MAAMA,CAAC,CAAC;AAAA,IACpH;AAAA,IACD,CAAC,CAAC;AAAA,EACN;AACE,EAAAL,EAAEL,GAAGM,GAAGJ,GAAGM,CAAC;AACd;AC3EO,SAASY,EACdC,GACAC,GACAC,IAAgB,IAChBC,GACA;AACA,QAAMC,IAAyBC,EAAO,IAAIC,EAAY,CAAC,CAAC,GAElDC,IAAkBC;AAAA,IACtB,CAACC,MAAkC;AAC3B,YAAA,EAAE,eAAAC,EAAkB,IAAAD;AAClB,cAAA,IAAI,mBAAmBC,CAAa,GACrBN,EAAA,QAAQ,IAAIM,CAAa,GAE5CT,KACFA,EAASQ,CAAU;AAAA,IAEvB;AAAA,IACA,CAACR,CAAQ;AAAA,EAAA;AAGMU,SAAAA,EAAAX,GAAYO,GAAiBL,GAAeC,CAAO,GAE7D,EAAE,qBAAqBC,EAAuB;AACvD;"}
@@ -0,0 +1,2 @@
1
+ export * from './useSectionScrollSpring';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { SpringValue } from '@react-spring/web';
2
+ import { IntersectionObserverOptions, SectionScrollInfo } from '@react-scrollytelling/core';
3
+
4
+ /**
5
+ * Get the state of the section scroll
6
+ * @param sectionRef - The reference to the section element
7
+ * @param shouldObserve - Whether the underlying IntersectionObserver should be active
8
+ * @param onScroll - The callback to track the scroll ratio
9
+ */
10
+ export declare function useSectionScrollSpring(sectionRef: React.RefObject<Element>, onScroll?: (scrollInfo: SectionScrollInfo) => void, shouldObserve?: boolean, options?: IntersectionObserverOptions): {
11
+ scrolledRatioSpring: SpringValue<number>;
12
+ };
13
+ //# sourceMappingURL=useSectionScrollSpring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSectionScrollSpring.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSectionScrollSpring.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,EACpC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,IAAI,EAClD,aAAa,UAAO,EACpB,OAAO,CAAC,EAAE,2BAA2B;;EAoBtC"}
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@react-scrollytelling/react-spring",
3
+ "version": "0.0.1",
4
+ "description": "> TODO: description",
5
+ "author": "@hsunpei",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "homepage": "https://github.com/hsunpei/react-scrollytelling#readme",
11
+ "main": "dist/index.cjs.js",
12
+ "module": "dist/index.es.js",
13
+ "types": "./dist/src/index.d.ts",
14
+ "sideEffects": false,
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/hsunpei/react-scrollytelling.git"
21
+ },
22
+ "scripts": {
23
+ "dev": "BUILD_MODE=dev yarn dev:dist",
24
+ "dev:dist": "yarn build:dist --watch",
25
+ "dev:declarations": "tsc -p . --emitDeclarationOnly --watch --outDir dist_types",
26
+ "build": "run-s build:dist build:declarations",
27
+ "build:dist": "vite build",
28
+ "build:declarations": "tsc -p . --emitDeclarationOnly --outDir dist_types",
29
+ "clean": "rimraf -rf ./dist && rimraf -rf ./dist_types",
30
+ "test": "jest",
31
+ "test:watch": "jest --watch"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/hsunpei/react-scrollytelling/issues"
35
+ },
36
+ "devDependencies": {
37
+ "@testing-library/dom": "^10.4.0",
38
+ "@testing-library/jest-dom": "^6.4.8",
39
+ "@testing-library/react": "^16.0.0",
40
+ "jest": "^29.7.0",
41
+ "jest-environment-jsdom": "^29.7.0",
42
+ "ts-jest": "^29.2.4",
43
+ "vite": "^5.2.11"
44
+ },
45
+ "peerDependencies": {
46
+ "react": "^18.2.0",
47
+ "react-dom": "^18.2.0",
48
+ "react-spring": "^9.7.5"
49
+ },
50
+ "gitHead": "0755e926c96e557be7055da7d8174fe94ffbb3de"
51
+ }