@zenpatient-org/healthspan-marketing-ui 0.1.94 → 0.1.95
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/dist/components/InfiniteScroll/InfiniteScroll.cjs.js +1 -1
- package/dist/components/InfiniteScroll/InfiniteScroll.es.js +77 -64
- package/dist/healthspan-marketing-ui.css +1 -1
- package/dist/modules/FeaturedIn/FeaturedIn.cjs.js +1 -1
- package/dist/modules/FeaturedIn/FeaturedIn.es.js +10 -10
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),t=require("react"),v=require("../../utils/cn/cn.cjs.js"),M=require("./infiniteScroll.module.css.cjs.js");function N({items:u,speed:R=50,direction:h="left",contentClassName:T,itemClassName:F,rootClassName:P,renderItem:k},x){const i=t.useRef(null),S=t.useRef(null),f=t.useRef(null),d=t.useRef(!1),p=t.useRef(performance.now()),[m,y]=t.useState(0),[r,j]=t.useState(0),[s,E]=t.useState(4),q=t.useCallback(()=>{if(!S.current||!i.current||u.length===0)return;const e=S.current.scrollWidth/s,o=i.current.offsetWidth,l=Math.ceil(o*2.5/e),a=Math.max(4,Math.min(20,l%2===0?l:l+1));E(a),j(e);const c=Math.floor(a/2);y(-e*c)},[u.length,s]);t.useEffect(()=>{q();const n=new ResizeObserver(()=>{q()});return i.current&&n.observe(i.current),()=>n.disconnect()},[q]);const C=t.useCallback(n=>{if(d.current||r===0){f.current=requestAnimationFrame(C);return}const e=n??performance.now(),o=e-p.current||16.67;p.current=e,y(l=>{const a=h==="right"?-R:R;let c=l-a*(o/1e3);const W=r*s,g=r*Math.floor(s/2);return h==="left"&&c<=-W+g?c+r:h==="right"&&c>=g?c-r:c}),f.current=requestAnimationFrame(C)},[h,R,r,s]);t.useEffect(()=>(p.current=performance.now(),f.current=requestAnimationFrame(C),()=>{f.current&&cancelAnimationFrame(f.current)}),[C]);const I=t.useCallback(n=>{d.current=!0,n.pointerType==="mouse"&&(d.current=!0)},[]),L=t.useCallback(n=>{n.pointerType==="mouse"&&(d.current=!1,p.current=performance.now())},[]),w=t.useCallback((n,e=300)=>{const o=m,l=n-o,a=performance.now(),c=W=>{const g=W-a,A=Math.min(g/e,1),_=1-Math.pow(1-A,3);y(o+l*_),A<1&&requestAnimationFrame(c)};requestAnimationFrame(c)},[m]);return t.useImperativeHandle(x,()=>({scrollLeft:()=>{const n=r*s,e=-r*Math.floor(s/2);let o=m-200;o<-n+e&&(o+=r),w(o)},scrollRight:()=>{const n=-r*Math.floor(s/2);let e=m+200;e>n&&(e-=r),w(e)}})),b.jsx("div",{className:v.cn(M.default.root,P),ref:i,onPointerEnter:I,onPointerLeave:L,children:b.jsx("div",{className:v.cn(M.default.content,T),ref:S,style:{transform:`translate3d(${m}px, 0, 0)`},children:Array.from({length:u.length*s},(n,e)=>b.jsx("div",{className:v.cn(M.default.item,F),children:k(u[e%u.length],e)},e))})})}const O=t.forwardRef(N);exports.InfiniteScroll=O;
|
|
@@ -1,82 +1,95 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as H, useRef as
|
|
4
|
-
import { cn as
|
|
5
|
-
import
|
|
6
|
-
function
|
|
7
|
-
items:
|
|
8
|
-
speed:
|
|
9
|
-
direction:
|
|
10
|
-
contentClassName:
|
|
11
|
-
itemClassName:
|
|
12
|
-
rootClassName:
|
|
13
|
-
renderItem:
|
|
14
|
-
},
|
|
15
|
-
const i =
|
|
16
|
-
|
|
17
|
-
i.current
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} else if (c === "right" && e >= 0)
|
|
35
|
-
return e - r;
|
|
36
|
-
return e;
|
|
37
|
-
});
|
|
2
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as H, useRef as m, useState as A, useCallback as h, useEffect as b, useImperativeHandle as _ } from "react";
|
|
4
|
+
import { cn as q } from "../../utils/cn/cn.es.js";
|
|
5
|
+
import F from "./infiniteScroll.module.css.es.js";
|
|
6
|
+
function $({
|
|
7
|
+
items: a,
|
|
8
|
+
speed: W = 50,
|
|
9
|
+
direction: d = "left",
|
|
10
|
+
contentClassName: x,
|
|
11
|
+
itemClassName: L,
|
|
12
|
+
rootClassName: E,
|
|
13
|
+
renderItem: I
|
|
14
|
+
}, N) {
|
|
15
|
+
const i = m(null), v = m(null), u = m(null), p = m(!1), g = m(performance.now()), [f, w] = A(0), [n, X] = A(0), [c, O] = A(4), M = h(() => {
|
|
16
|
+
if (!v.current || !i.current || a.length === 0) return;
|
|
17
|
+
const t = v.current.scrollWidth / c, r = i.current.offsetWidth, s = Math.ceil(r * 2.5 / t), l = Math.max(4, Math.min(20, s % 2 === 0 ? s : s + 1));
|
|
18
|
+
O(l), X(t);
|
|
19
|
+
const o = Math.floor(l / 2);
|
|
20
|
+
w(-t * o);
|
|
21
|
+
}, [a.length, c]);
|
|
22
|
+
b(() => {
|
|
23
|
+
M();
|
|
24
|
+
const e = new ResizeObserver(() => {
|
|
25
|
+
M();
|
|
26
|
+
});
|
|
27
|
+
return i.current && e.observe(i.current), () => e.disconnect();
|
|
28
|
+
}, [M]);
|
|
29
|
+
const y = h(
|
|
30
|
+
(e) => {
|
|
31
|
+
if (p.current || n === 0) {
|
|
32
|
+
u.current = requestAnimationFrame(y);
|
|
33
|
+
return;
|
|
38
34
|
}
|
|
39
|
-
|
|
35
|
+
const t = e ?? performance.now(), r = t - g.current || 16.67;
|
|
36
|
+
g.current = t, w((s) => {
|
|
37
|
+
const l = d === "right" ? -W : W;
|
|
38
|
+
let o = s - l * (r / 1e3);
|
|
39
|
+
const R = n * c, C = n * Math.floor(c / 2);
|
|
40
|
+
return d === "left" && o <= -R + C ? o + n : d === "right" && o >= C ? o - n : o;
|
|
41
|
+
}), u.current = requestAnimationFrame(y);
|
|
40
42
|
},
|
|
41
|
-
[
|
|
43
|
+
[d, W, n, c]
|
|
42
44
|
);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}), [
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
}, []),
|
|
49
|
-
|
|
50
|
-
}, []),
|
|
51
|
-
(
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
45
|
+
b(() => (g.current = performance.now(), u.current = requestAnimationFrame(y), () => {
|
|
46
|
+
u.current && cancelAnimationFrame(u.current);
|
|
47
|
+
}), [y]);
|
|
48
|
+
const j = h((e) => {
|
|
49
|
+
p.current = !0, e.pointerType === "mouse" && (p.current = !0);
|
|
50
|
+
}, []), k = h((e) => {
|
|
51
|
+
e.pointerType === "mouse" && (p.current = !1, g.current = performance.now());
|
|
52
|
+
}, []), T = h(
|
|
53
|
+
(e, t = 300) => {
|
|
54
|
+
const r = f, s = e - r, l = performance.now(), o = (R) => {
|
|
55
|
+
const C = R - l, P = Math.min(C / t, 1), z = 1 - Math.pow(1 - P, 3);
|
|
56
|
+
w(r + s * z), P < 1 && requestAnimationFrame(o);
|
|
55
57
|
};
|
|
56
|
-
requestAnimationFrame(
|
|
58
|
+
requestAnimationFrame(o);
|
|
57
59
|
},
|
|
58
|
-
[
|
|
60
|
+
[f]
|
|
59
61
|
);
|
|
60
|
-
return
|
|
62
|
+
return _(N, () => ({
|
|
61
63
|
scrollLeft: () => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
+
const e = n * c, t = -n * Math.floor(c / 2);
|
|
65
|
+
let r = f - 200;
|
|
66
|
+
r < -e + t && (r += n), T(r);
|
|
64
67
|
},
|
|
65
68
|
scrollRight: () => {
|
|
66
|
-
const
|
|
67
|
-
|
|
69
|
+
const e = -n * Math.floor(c / 2);
|
|
70
|
+
let t = f + 200;
|
|
71
|
+
t > e && (t -= n), T(t);
|
|
68
72
|
}
|
|
69
|
-
})), /* @__PURE__ */
|
|
73
|
+
})), /* @__PURE__ */ S(
|
|
70
74
|
"div",
|
|
71
75
|
{
|
|
72
|
-
className:
|
|
73
|
-
style: { transform: `translate3D(${u}px, 0, 0)` },
|
|
76
|
+
className: q(F.root, E),
|
|
74
77
|
ref: i,
|
|
75
|
-
|
|
78
|
+
onPointerEnter: j,
|
|
79
|
+
onPointerLeave: k,
|
|
80
|
+
children: /* @__PURE__ */ S(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: q(F.content, x),
|
|
84
|
+
ref: v,
|
|
85
|
+
style: { transform: `translate3d(${f}px, 0, 0)` },
|
|
86
|
+
children: Array.from({ length: a.length * c }, (e, t) => /* @__PURE__ */ S("div", { className: q(F.item, L), children: I(a[t % a.length], t) }, t))
|
|
87
|
+
}
|
|
88
|
+
)
|
|
76
89
|
}
|
|
77
|
-
)
|
|
90
|
+
);
|
|
78
91
|
}
|
|
79
|
-
const
|
|
92
|
+
const K = H($);
|
|
80
93
|
export {
|
|
81
|
-
|
|
94
|
+
K as InfiniteScroll
|
|
82
95
|
};
|