swipefeed 1.0.0 → 1.0.2
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/index.js +2 -905
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,907 +1,4 @@
|
|
|
1
|
-
// src/hooks/useSwipeDeck.ts
|
|
2
|
-
import { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
1
|
+
import{useCallback as x,useEffect as j0,useMemo as o,useRef as g,useState as K0}from"react";function r(Q,X,$){if(Number.isNaN(Q))return X;return Math.min(Math.max(Q,X),$)}var J0=null;function B0(){if(J0!==null)return J0;if(typeof window>"u"||typeof window.matchMedia!=="function")return J0=!1,J0;return J0=window.matchMedia("(prefers-reduced-motion: reduce)").matches,J0}import{useCallback as a,useRef as g0,useState as m0,useMemo as v0}from"react";function b0(Q,X){return X==="vertical"?Q.clientY:Q.clientX}function T0(Q){let{orientation:X,direction:$,threshold:M,flickVelocity:K,lockAxis:S,ignoreWhileAnimating:y,loop:q,getIndex:O,maxIndex:h,onRequestIndexChange:P,setAnimating:C,isAnimating:B,onDragStart:Y,onDrag:H,onDragEnd:_}=Q,[E,L]=m0(!1),Z=g0({isDragging:!1,start:0,last:0,delta:0,startTime:0}),b=a((j)=>{j.currentTarget.setPointerCapture?.(j.pointerId);let z=b0(j,X);Z.current={isDragging:!0,start:z,last:z,delta:0,startTime:performance.now()},L(!0),Y?.(j)},[X,Y]),w=a((j)=>{if(!Z.current.isDragging)return;let z=b0(j,X),I=z-Z.current.start;Z.current.delta=I,Z.current.last=z,H?.(I,j)},[X,H]),F=a(()=>{if(!Z.current.isDragging)return;let j=performance.now(),z=Math.max(j-Z.current.startTime,1),I=Math.abs(Z.current.delta),D=I/z,G=(()=>{let e=Z.current.delta;if(X==="vertical")return e<0;return($==="rtl"?e*-1:e)<0})(),d=O(),A=G?1:-1,i=D>K,t=I>M,v=d;if(i||t)v=d+A;if(q)v=(v+(h+1))%(h+1);else v=r(v,0,h);C(!0),P(v),Z.current.isDragging=!1,Z.current.delta=0,L(!1),_?.()},[$,K,O,h,P,X,q,C,M,_]),n=a(()=>{Z.current.isDragging=!1,Z.current.delta=0,L(!1)},[]),R=a((j)=>{if(y&&B)return;if(j.button!==0)return;b(j)},[y,B,b]),m=a((j)=>{if(!S&&!Z.current.isDragging)return;if(Z.current.isDragging)w(j)},[S,w]),U=a(()=>{F()},[F]),N=a(()=>{n()},[n]);return v0(()=>({isDragging:E,handlers:{onPointerDown:R,onPointerMove:m,onPointerUp:U,onPointerCancel:N}}),[E,R,m,U,N])}import{useCallback as C0,useRef as s,useEffect as p0}from"react";function D0(Q){let{orientation:X,direction:$,discretePaging:M,threshold:K,debounce:S,cooldown:y=500,onRequestIndexChange:q,viewport:O,onDragStart:h,onDrag:P,onDragEnd:C}=Q,B=s(0),Y=s(null),H=s(0),_=s(!1),E=s(0),L=s(null),Z=s(0),b=s(!1),w=s(0),F=120,n=40,R=C0(()=>{b.current=!1,B.current=0,L.current=null,Z.current=0,w.current=0,C?.()},[C]),m=C0(()=>{if(Y.current)clearTimeout(Y.current);Y.current=setTimeout(()=>{R()},S)},[S,R]);p0(()=>{let U=O;if(!U)return;let N=(j)=>{if(!M)return;j.preventDefault(),j.stopPropagation();let z=performance.now();if(_.current){if(z-H.current<y){if(b.current)R();return}_.current=!1}let I=X==="vertical"?j.deltaY:j.deltaX,D=X==="horizontal"&&$==="rtl"?-I:I,G=D>0?1:-1;if(L.current!==null&&L.current!==G)B.current=0,Z.current=0;if(L.current=G,!b.current)b.current=!0,h?.();let d=z-E.current;E.current=z,Z.current++;let A=Math.sign(D)*Math.min(Math.abs(D),120),i=Math.sign(D)*Math.min(Math.abs(D),40),t=d>0&&d<100?Math.abs(A/d):0;w.current=w.current*0.8+t*0.2,B.current+=A,P?.(-i),m();let v=Math.abs(B.current)>=K,e=w.current>1.2&&Math.abs(B.current)>20;if(v||e){let Q0=B.current>0?1:-1;if(R(),H.current=z,_.current=!0,Y.current)clearTimeout(Y.current);q(Q0)}};return U.addEventListener("wheel",N,{passive:!1}),()=>{if(U.removeEventListener("wheel",N),Y.current)clearTimeout(Y.current)}},[X,$,M,K,y,q,m,O,R,h,P])}import{useCallback as u0,useEffect as c0}from"react";var d0={prev:["ArrowUp"],next:["ArrowDown"],first:["Home"],last:["End"],altPrev:["PageUp"],altNext:["PageDown"]},l0={prev:["ArrowLeft"],next:["ArrowRight"],first:["Home"],last:["End"],altPrev:["PageUp"],altNext:["PageDown"]};function k0(Q){let{orientation:X,direction:$,config:M,onPrev:K,onNext:S,onFirst:y,onLast:q}=Q,O=M?.enabled??!0,h=M?.global??!1,P=M?.bindings??(X==="vertical"?d0:l0),C=u0((B)=>{if(!O)return;let Y=B.key,H=[...P.prev??[],...P.altPrev??[]],_=[...P.next??[],...P.altNext??[]],E=X==="horizontal",L=$==="rtl";if(H.includes(Y)){if(B.preventDefault(),E&&L)S();else K();return}if(_.includes(Y)){if(B.preventDefault(),E&&L)K();else S();return}if(P.first?.includes(Y)){B.preventDefault(),y?.();return}if(P.last?.includes(Y)){B.preventDefault(),q?.();return}},[P,$,O,y,q,S,K,X]);return c0(()=>{if(!O||!h)return;return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[O,h,C]),{onKeyDown:C}}import{useEffect as r0,useLayoutEffect as s0,useState as a0,useMemo as S0,useCallback as n0}from"react";import{useVirtualizer as o0}from"@tanstack/react-virtual";var i0=typeof window<"u"?s0:r0;function w0(Q){let{items:X,virtual:$,getScrollElement:M,orientation:K="vertical"}=Q,S=X.length,[y,q]=a0(()=>{return{size:typeof window<"u"?K==="vertical"?window.innerHeight:window.innerWidth:800,measured:!1}});i0(()=>{let Y=M();if(!Y)return;let H=()=>{let E=K==="vertical"?Y.clientHeight:Y.clientWidth;if(E>0)q((L)=>{if(L.size!==E||!L.measured)return{size:E,measured:!0};return L})};H();let _=new ResizeObserver(H);return _.observe(Y),()=>{_.disconnect()}},[M,K]);let O=y.size,h=n0((Y)=>{let H=$?.estimatedSize;if(typeof H==="function")return H(X[Y],Y);if(O>0)return O;return typeof H==="number"?H:800},[$?.estimatedSize,X,O]),P=S0(()=>{if(typeof window>"u")return{width:800,height:800};return{width:window.innerWidth,height:window.innerHeight}},[]),C=S0(()=>{if(!$?.getItemKey)return;return(Y)=>$.getItemKey?.(X[Y],Y)??Y},[$?.getItemKey,X]),B=o0({count:S,getScrollElement:M,estimateSize:h,overscan:$?.overscan??5,horizontal:K==="horizontal",getItemKey:C,initialRect:P});return{virtualItems:B.getVirtualItems().map((Y)=>({index:Y.index,key:Y.key,offset:Y.start,size:Y.size,measureElement:B.measureElement})),totalSize:B.getTotalSize(),getItemOffset:(Y)=>{let H=B.getVirtualItems().find((_)=>_.index===Y);return H?H.start:0},getItemSize:(Y)=>{let H=B.getVirtualItems().find((_)=>_.index===Y);return H?H.size:0},scrollToIndex:(Y,H)=>{B.scrollToIndex(Y,{align:H?.align,behavior:H?.behavior})},containerSize:O}}var c={orientation:"vertical",direction:"ltr",loop:!1,defaultIndex:0,gesture:{threshold:10,flickVelocity:0.1,lockAxis:!0,ignoreWhileAnimating:!0},wheel:{discretePaging:!0,threshold:100,debounce:120,cooldown:800},keyboard:{enabled:!0},visibility:{strategy:"position",intersectionRatio:0.6,debounce:100},virtual:{overscan:5},endReachedThreshold:3,ariaLabel:"Swipe feed",keyboardNavigation:!0};function O0(Q){let X=Q.items??[],$=Q.orientation??c.orientation,M=Q.direction??c.direction,K=Q.loop??c.loop,S=Q.defaultIndex??c.defaultIndex,y=Q.preload??0,q=Q.preloadPrevious??0,O=o(()=>({...c.gesture,...Q.gesture??{}}),[Q.gesture]),h=o(()=>({...c.wheel,...Q.wheel??{}}),[Q.wheel]),P=o(()=>({...c.keyboard,...Q.keyboard??{}}),[Q.keyboard]),C=o(()=>{let J={...c.virtual,...Q.virtual??{}},W=Math.max(y,q);return{...J,overscan:Math.max(J.overscan??0,W)}},[Q.virtual,y,q]),B=Q.endReachedThreshold??c.endReachedThreshold,Y=Q.ariaLabel??c.ariaLabel,H=Q.keyboardNavigation??!0,_=typeof Q.index==="number",[E,L]=K0(()=>r(S,0,Math.max(X.length-1,0))),Z=_?r(Q.index??0,0,Math.max(X.length-1,0)):E,[b,w]=K0(!1),[F,n]=K0(null),R=g("snap"),m=g(0),U=g(!1),N=g(null),j=g(0),z=g(-1),I=g(0);j0(()=>{let J=r(Z,0,Math.max(X.length-1,0));if(!_)L(J)},[Z,_,X.length]);let D=w0({items:X,virtual:C,getScrollElement:x(()=>F,[F]),orientation:$}),G=g({index:Z,items:X,isControlled:_,options:Q,virtualizer:D,loop:K,orientation:$,setInternalIndex:L,setIsAnimating:w,viewport:F});G.current={index:Z,items:X,isControlled:_,options:Q,virtualizer:D,loop:K,orientation:$,setInternalIndex:L,setIsAnimating:w,viewport:F};let d=x((J)=>{let{index:W,isControlled:V,options:T,setInternalIndex:f,setIsAnimating:k}=G.current;if(J===W)return;if(!V)f(J);T.onIndexChange?.(J,R.current??"snap"),k(!1),R.current="snap"},[]),A=x((J,W,V)=>{let{items:T,loop:f,index:k,isControlled:l,options:W0,orientation:h0,virtualizer:I0,setInternalIndex:f0,viewport:p}=G.current;if(T.length===0)return;let x0=T.length-1,u=J;if(f)u=(u+T.length)%T.length;else u=r(u,0,x0);if(u===k&&W!=="snap")return;let E0=Date.now();if(u===z.current&&E0-I.current<300)return;if(z.current=u,I.current=E0,R.current=W,U.current=!0,!l)f0(u);if(W0.onIndexChange?.(u,W),!p)return;if(N.current)clearTimeout(N.current),N.current=null;p.style.scrollSnapType="none",p.style.scrollBehavior="auto";let _0=V??(B0()?"instant":"smooth"),z0=u*I0.containerSize;if(j.current=Date.now(),h0==="vertical")p.scrollTo({top:z0,behavior:_0});else p.scrollTo({left:z0,behavior:_0});let H0=()=>{if(U.current=!1,N.current)clearTimeout(N.current),N.current=null;if(p)p.style.scrollSnapType=h0==="vertical"?"y mandatory":"x mandatory"};if("onscrollend"in window){let Y0=()=>{H0(),p.removeEventListener("scrollend",Y0)};p.addEventListener("scrollend",Y0,{once:!0}),N.current=setTimeout(()=>{p.removeEventListener("scrollend",Y0),H0()},800)}else{let Y0=_0==="smooth"?500:50;N.current=setTimeout(H0,Y0)}},[]),i=x(()=>{let{viewport:J,orientation:W}=G.current;if(J)J.style.scrollBehavior="auto",m.current=W==="vertical"?J.scrollTop:J.scrollLeft},[]),t=x((J)=>{let{viewport:W,orientation:V}=G.current;if(W){let T=m.current-J;if(V==="vertical")W.scrollTop=T;else W.scrollLeft=T}},[]),v=x(()=>{let{viewport:J,orientation:W,items:V,virtualizer:T}=G.current;if(!J||V.length===0)return G.current.index;let f=W==="vertical"?J.scrollTop:J.scrollLeft,k=T.containerSize||J.clientHeight;if(k<=0)return G.current.index;let l=Math.round(f/k);return r(l,0,V.length-1)},[]),e=D0({orientation:$,direction:M,discretePaging:h.discretePaging??!0,threshold:h.threshold??80,debounce:h.debounce??120,cooldown:h.cooldown??400,onRequestIndexChange:(J)=>A(G.current.index+J,"user:wheel"),viewport:F,onDragStart:i,onDrag:t,onDragEnd:()=>{let J=v();A(J,"snap")}}),Q0=T0({orientation:$,direction:M,threshold:O.threshold??50,flickVelocity:O.flickVelocity??0.5,lockAxis:O.lockAxis??!0,ignoreWhileAnimating:O.ignoreWhileAnimating??!0,loop:K,getIndex:()=>G.current.index,maxIndex:Math.max(X.length-1,0),onRequestIndexChange:(J)=>A(J,"user:gesture"),setAnimating:w,isAnimating:b,onDragStart:i,onDrag:t}),M0=k0({orientation:$,direction:M,config:H?P:{enabled:!1},onPrev:()=>A(G.current.index-1,"user:keyboard"),onNext:()=>A(G.current.index+1,"user:keyboard"),onFirst:()=>A(0,"user:keyboard"),onLast:()=>A(X.length-1,"user:keyboard")}),Z0=g(null),q0=g(null),L0=x(()=>{if(U.current&&Date.now()-j.current>1500)U.current=!1,console.warn("[SwipeDeck] Navigation lock timeout - forcing unlock");if(U.current)return;if(q0.current)clearTimeout(q0.current);if(q0.current=setTimeout(()=>{if(U.current)return;let{viewport:J,orientation:W,index:V}=G.current;if(!J)return;let T=W==="vertical"?J.scrollTop:J.scrollLeft,f=W==="vertical"?J.clientHeight:J.clientWidth,k=V*f,l=typeof window<"u"?window.devicePixelRatio:1,W0=Math.max(5,Math.ceil(5*l));if(Math.abs(T-k)>W0)J.scrollTo({top:W==="vertical"?k:0,left:W==="horizontal"?k:0,behavior:"smooth"})},150),Z0.current!==null)return;Z0.current=requestAnimationFrame(()=>{if(Z0.current=null,U.current)return;let{viewport:J,orientation:W,items:V}=G.current;if(!J)return;let T=W==="vertical"?J.scrollTop:J.scrollLeft,f=W==="vertical"?J.clientHeight:J.clientWidth;if(f>0&&V.length>0){let k=Math.round(T/f),l=r(k,0,V.length-1);d(l)}})},[d]);j0(()=>{if(X.length===0)return;let W=X.length-1-Z;if(W<=B)Q.onEndReached?.({distanceFromEnd:W,direction:"forward"});if(Z<=B)Q.onEndReached?.({distanceFromEnd:Z,direction:"backward"})},[B,Z,X.length,Q]);let F0=o(()=>B0()?"instant":"smooth",[]),q1=x((J,W)=>{A(J,"programmatic",W?.behavior??F0)},[A,F0]),V0=o(()=>({index:Z,isAnimating:b,canPrev:K||Z>0,canNext:K||Z<X.length-1}),[Z,b,X.length,K]),X0=g(null);j0(()=>{if(!F)return;let W=new ResizeObserver(()=>{if(X0.current)clearTimeout(X0.current);X0.current=setTimeout(()=>{let{orientation:V,index:T}=G.current;if(!F)return;let f=V==="vertical"?F.clientHeight:F.clientWidth,k=T*f,l=V==="vertical"?F.scrollTop:F.scrollLeft;if(Math.abs(l-k)>f*0.1)if(V==="vertical")F.scrollTop=k;else F.scrollLeft=k},50)});return W.observe(F),()=>{if(W.disconnect(),X0.current)clearTimeout(X0.current)}},[F]);let U0=x(()=>{let{viewport:J,orientation:W}=G.current;if(J)J.style.scrollSnapType=W==="vertical"?"y mandatory":"x mandatory"},[]),N0=x(()=>{let J={position:"relative",overflow:"auto",scrollSnapType:$==="vertical"?"y mandatory":"x mandatory",touchAction:$==="vertical"?"pan-y":"pan-x",willChange:"scroll-position"};return{ref:n,role:"feed","aria-label":Y,"aria-busy":b,tabIndex:0,onScroll:L0,onKeyDown:M0.onKeyDown,onTouchStart:U0,...Q0.handlers,style:J}},[Y,L0,U0,b,M0.onKeyDown,$,Q0.handlers]),P0=x((J)=>{let W=Z===J,V=$==="vertical"?"100dvh":"100dvw";return{ref:void 0,"data-index":J,"data-active":W,style:{position:"absolute",top:0,left:0,transform:$==="vertical"?`translateY(calc(${J} * ${V}))`:`translateX(calc(${J} * ${V}))`,height:$==="vertical"?V:"100%",width:$==="horizontal"?V:"100%",willChange:"transform",scrollSnapAlign:"start",scrollSnapStop:"always"}}},[Z,$]),A0=x(()=>A(G.current.index-1,"user:keyboard"),[A]),y0=x(()=>A(G.current.index+1,"user:keyboard"),[A]);return o(()=>({...V0,prev:A0,next:y0,scrollTo:(J,W)=>A(J,"programmatic",W?.behavior),getViewportProps:N0,getItemProps:P0,virtualItems:D.virtualItems,totalSize:D.totalSize,items:X,orientation:$,viewport:F}),[V0,A0,y0,A,N0,P0,D.virtualItems,D.totalSize,X,$,F])}import{useState as t0,useEffect as e0}from"react";function J1(){let[Q,X]=t0({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0});return e0(()=>{if(typeof window>"u")return;let $,M=()=>{clearTimeout($),$=setTimeout(()=>{X({width:window.innerWidth,height:window.innerHeight})},100)};return window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M),clearTimeout($)}},[]),Q}import{createContext as Q1,useContext as X1}from"react";var G0=Q1(void 0);function Y1(){let Q=X1(G0);if(!Q)throw Error("useSwipeItem must be used within a SwipeDeck item");return Q}import{useImperativeHandle as $1,useMemo as R0}from"react";import{jsx as $0}from"react/jsx-runtime";function Z1(Q){let{as:X="div",children:$,className:M,style:K,ref:S,...y}=Q,q=O0(y);$1(S,()=>({prev:q.prev,next:q.next,scrollTo:q.scrollTo,getState:()=>({index:q.index,isAnimating:q.isAnimating,canPrev:q.canPrev,canNext:q.canNext}),viewport:q.viewport}),[q]);let{style:O,...h}=q.getViewportProps(),P=Q.fullscreen?{height:"100dvh",width:"100%",position:"absolute",top:0,left:0}:{},C=R0(()=>({...O,...P,...K}),[O,P,K]),B=R0(()=>({height:q.orientation==="vertical"?`calc(${q.items.length} * 100dvh)`:"100%",width:q.orientation==="horizontal"?`calc(${q.items.length} * 100dvw)`:"100%",position:"relative"}),[q.orientation,q.items.length]);return $0(X,{...h,className:M,style:C,children:$0("div",{style:B,children:q.virtualItems.map((H)=>{let _=H.index,E=q.items[_];if(!E)return null;let L=q.getItemProps(_),Z=y.preload??0,b=y.preloadPrevious??0,w=!1;if(Z>0||b>0){let U=q.index;if(!y.loop){let N=_>U&&_<=U+Z,j=_<U&&_>=U-b;w=N||j}else{let N=q.items.length,j=(_-U+N)%N,z=(U-_+N)%N,I=j>0&&j<=Z,D=z>0&&z<=b;w=I||D}}let{style:F,...n}=L,R={item:E,index:_,isActive:q.index===_,shouldPreload:w,props:n},m=H.key??(y.virtual?.getItemKey?.(E,_)??_);return $0("article",{...L,"aria-label":`Item ${_+1} of ${q.items.length}`,children:$0(G0.Provider,{value:R,children:$(R)})},m)})})})}export{J1 as useWindowSize,Y1 as useSwipeItem,O0 as useSwipeDeck,Z1 as SwipeDeck};
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
function clamp(value, min, max) {
|
|
6
|
-
if (Number.isNaN(value))
|
|
7
|
-
return min;
|
|
8
|
-
return Math.min(Math.max(value, min), max);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// src/utils/prefersReducedMotion.ts
|
|
12
|
-
var cached = null;
|
|
13
|
-
function prefersReducedMotion() {
|
|
14
|
-
if (cached !== null)
|
|
15
|
-
return cached;
|
|
16
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
17
|
-
cached = false;
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
cached = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
21
|
-
return cached;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/hooks/useGestures.ts
|
|
25
|
-
import { useCallback, useRef, useState, useMemo } from "react";
|
|
26
|
-
function primaryCoord(evt, orientation) {
|
|
27
|
-
return orientation === "vertical" ? evt.clientY : evt.clientX;
|
|
28
|
-
}
|
|
29
|
-
function useGestures(params) {
|
|
30
|
-
const {
|
|
31
|
-
orientation,
|
|
32
|
-
direction,
|
|
33
|
-
threshold,
|
|
34
|
-
flickVelocity,
|
|
35
|
-
lockAxis,
|
|
36
|
-
ignoreWhileAnimating,
|
|
37
|
-
loop,
|
|
38
|
-
getIndex,
|
|
39
|
-
maxIndex,
|
|
40
|
-
onRequestIndexChange,
|
|
41
|
-
setAnimating,
|
|
42
|
-
isAnimating,
|
|
43
|
-
onDragStart,
|
|
44
|
-
onDrag,
|
|
45
|
-
onDragEnd
|
|
46
|
-
} = params;
|
|
47
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
48
|
-
const state = useRef({
|
|
49
|
-
isDragging: false,
|
|
50
|
-
start: 0,
|
|
51
|
-
last: 0,
|
|
52
|
-
delta: 0,
|
|
53
|
-
startTime: 0
|
|
54
|
-
});
|
|
55
|
-
const startDrag = useCallback((evt) => {
|
|
56
|
-
evt.currentTarget.setPointerCapture?.(evt.pointerId);
|
|
57
|
-
const coord = primaryCoord(evt, orientation);
|
|
58
|
-
state.current = {
|
|
59
|
-
isDragging: true,
|
|
60
|
-
start: coord,
|
|
61
|
-
last: coord,
|
|
62
|
-
delta: 0,
|
|
63
|
-
startTime: performance.now()
|
|
64
|
-
};
|
|
65
|
-
setIsDragging(true);
|
|
66
|
-
onDragStart?.(evt);
|
|
67
|
-
}, [orientation, onDragStart]);
|
|
68
|
-
const updateDrag = useCallback((evt) => {
|
|
69
|
-
if (!state.current.isDragging)
|
|
70
|
-
return;
|
|
71
|
-
const coord = primaryCoord(evt, orientation);
|
|
72
|
-
const delta = coord - state.current.start;
|
|
73
|
-
state.current.delta = delta;
|
|
74
|
-
state.current.last = coord;
|
|
75
|
-
onDrag?.(delta, evt);
|
|
76
|
-
}, [orientation, onDrag]);
|
|
77
|
-
const endDrag = useCallback(() => {
|
|
78
|
-
if (!state.current.isDragging)
|
|
79
|
-
return;
|
|
80
|
-
const now = performance.now();
|
|
81
|
-
const duration = Math.max(now - state.current.startTime, 1);
|
|
82
|
-
const distance = Math.abs(state.current.delta);
|
|
83
|
-
const velocity = distance / duration;
|
|
84
|
-
const isForward = (() => {
|
|
85
|
-
const raw = state.current.delta;
|
|
86
|
-
if (orientation === "vertical")
|
|
87
|
-
return raw < 0;
|
|
88
|
-
const normalized = direction === "rtl" ? raw * -1 : raw;
|
|
89
|
-
return normalized < 0;
|
|
90
|
-
})();
|
|
91
|
-
const current = getIndex();
|
|
92
|
-
const deltaSign = isForward ? 1 : -1;
|
|
93
|
-
const meetsFlick = velocity > flickVelocity;
|
|
94
|
-
const meetsDistance = distance > threshold;
|
|
95
|
-
let next = current;
|
|
96
|
-
if (meetsFlick || meetsDistance) {
|
|
97
|
-
next = current + deltaSign;
|
|
98
|
-
}
|
|
99
|
-
if (loop) {
|
|
100
|
-
next = (next + (maxIndex + 1)) % (maxIndex + 1);
|
|
101
|
-
} else {
|
|
102
|
-
next = clamp(next, 0, maxIndex);
|
|
103
|
-
}
|
|
104
|
-
setAnimating(true);
|
|
105
|
-
onRequestIndexChange(next);
|
|
106
|
-
state.current.isDragging = false;
|
|
107
|
-
state.current.delta = 0;
|
|
108
|
-
setIsDragging(false);
|
|
109
|
-
onDragEnd?.();
|
|
110
|
-
}, [direction, flickVelocity, getIndex, maxIndex, onRequestIndexChange, orientation, loop, setAnimating, threshold, onDragEnd]);
|
|
111
|
-
const cancelDrag = useCallback(() => {
|
|
112
|
-
state.current.isDragging = false;
|
|
113
|
-
state.current.delta = 0;
|
|
114
|
-
setIsDragging(false);
|
|
115
|
-
}, []);
|
|
116
|
-
const onPointerDown = useCallback((evt) => {
|
|
117
|
-
if (ignoreWhileAnimating && isAnimating)
|
|
118
|
-
return;
|
|
119
|
-
if (evt.button !== 0)
|
|
120
|
-
return;
|
|
121
|
-
startDrag(evt);
|
|
122
|
-
}, [ignoreWhileAnimating, isAnimating, startDrag]);
|
|
123
|
-
const onPointerMove = useCallback((evt) => {
|
|
124
|
-
if (!lockAxis && !state.current.isDragging)
|
|
125
|
-
return;
|
|
126
|
-
if (state.current.isDragging) {
|
|
127
|
-
updateDrag(evt);
|
|
128
|
-
}
|
|
129
|
-
}, [lockAxis, updateDrag]);
|
|
130
|
-
const onPointerUp = useCallback(() => {
|
|
131
|
-
endDrag();
|
|
132
|
-
}, [endDrag]);
|
|
133
|
-
const onPointerCancel = useCallback(() => {
|
|
134
|
-
cancelDrag();
|
|
135
|
-
}, [cancelDrag]);
|
|
136
|
-
return useMemo(() => ({
|
|
137
|
-
isDragging,
|
|
138
|
-
handlers: { onPointerDown, onPointerMove, onPointerUp, onPointerCancel }
|
|
139
|
-
}), [isDragging, onPointerDown, onPointerMove, onPointerUp, onPointerCancel]);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// src/hooks/useWheel.ts
|
|
143
|
-
import { useCallback as useCallback2, useRef as useRef2, useEffect } from "react";
|
|
144
|
-
function useWheel(params) {
|
|
145
|
-
const {
|
|
146
|
-
orientation,
|
|
147
|
-
direction,
|
|
148
|
-
discretePaging,
|
|
149
|
-
threshold,
|
|
150
|
-
debounce,
|
|
151
|
-
cooldown = 500,
|
|
152
|
-
onRequestIndexChange,
|
|
153
|
-
viewport,
|
|
154
|
-
onDragStart,
|
|
155
|
-
onDrag,
|
|
156
|
-
onDragEnd
|
|
157
|
-
} = params;
|
|
158
|
-
const accumulated = useRef2(0);
|
|
159
|
-
const timeoutRef = useRef2(null);
|
|
160
|
-
const lastNavigationTime = useRef2(0);
|
|
161
|
-
const isInCooldown = useRef2(false);
|
|
162
|
-
const lastEventTime = useRef2(0);
|
|
163
|
-
const gestureDirection = useRef2(null);
|
|
164
|
-
const eventCount = useRef2(0);
|
|
165
|
-
const isTracking = useRef2(false);
|
|
166
|
-
const velocityRef = useRef2(0);
|
|
167
|
-
const MAX_DELTA_ACCUMULATION = 120;
|
|
168
|
-
const MAX_VISUAL_DELTA = 40;
|
|
169
|
-
const endGesture = useCallback2(() => {
|
|
170
|
-
isTracking.current = false;
|
|
171
|
-
accumulated.current = 0;
|
|
172
|
-
gestureDirection.current = null;
|
|
173
|
-
eventCount.current = 0;
|
|
174
|
-
velocityRef.current = 0;
|
|
175
|
-
onDragEnd?.();
|
|
176
|
-
}, [onDragEnd]);
|
|
177
|
-
const resetAccumulated = useCallback2(() => {
|
|
178
|
-
if (timeoutRef.current)
|
|
179
|
-
clearTimeout(timeoutRef.current);
|
|
180
|
-
timeoutRef.current = setTimeout(() => {
|
|
181
|
-
endGesture();
|
|
182
|
-
}, debounce);
|
|
183
|
-
}, [debounce, endGesture]);
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
const element = viewport;
|
|
186
|
-
if (!element)
|
|
187
|
-
return;
|
|
188
|
-
const onWheel = (evt) => {
|
|
189
|
-
if (!discretePaging)
|
|
190
|
-
return;
|
|
191
|
-
evt.preventDefault();
|
|
192
|
-
evt.stopPropagation();
|
|
193
|
-
const now = performance.now();
|
|
194
|
-
if (isInCooldown.current) {
|
|
195
|
-
if (now - lastNavigationTime.current < cooldown) {
|
|
196
|
-
if (isTracking.current)
|
|
197
|
-
endGesture();
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
isInCooldown.current = false;
|
|
201
|
-
}
|
|
202
|
-
const rawDelta = orientation === "vertical" ? evt.deltaY : evt.deltaX;
|
|
203
|
-
const adjusted = orientation === "horizontal" && direction === "rtl" ? -rawDelta : rawDelta;
|
|
204
|
-
const currentDirection = adjusted > 0 ? 1 : -1;
|
|
205
|
-
if (gestureDirection.current !== null && gestureDirection.current !== currentDirection) {
|
|
206
|
-
accumulated.current = 0;
|
|
207
|
-
eventCount.current = 0;
|
|
208
|
-
}
|
|
209
|
-
gestureDirection.current = currentDirection;
|
|
210
|
-
if (!isTracking.current) {
|
|
211
|
-
isTracking.current = true;
|
|
212
|
-
onDragStart?.();
|
|
213
|
-
}
|
|
214
|
-
const timeDelta = now - lastEventTime.current;
|
|
215
|
-
lastEventTime.current = now;
|
|
216
|
-
eventCount.current++;
|
|
217
|
-
const accumDelta = Math.sign(adjusted) * Math.min(Math.abs(adjusted), MAX_DELTA_ACCUMULATION);
|
|
218
|
-
const visualDelta = Math.sign(adjusted) * Math.min(Math.abs(adjusted), MAX_VISUAL_DELTA);
|
|
219
|
-
const instantVelocity = timeDelta > 0 && timeDelta < 100 ? Math.abs(accumDelta / timeDelta) : 0;
|
|
220
|
-
velocityRef.current = velocityRef.current * 0.8 + instantVelocity * 0.2;
|
|
221
|
-
accumulated.current += accumDelta;
|
|
222
|
-
onDrag?.(-visualDelta);
|
|
223
|
-
resetAccumulated();
|
|
224
|
-
const matchesThreshold = Math.abs(accumulated.current) >= threshold;
|
|
225
|
-
const isFlick = velocityRef.current > 1.2 && Math.abs(accumulated.current) > 20;
|
|
226
|
-
if (matchesThreshold || isFlick) {
|
|
227
|
-
const navDelta = accumulated.current > 0 ? 1 : -1;
|
|
228
|
-
endGesture();
|
|
229
|
-
lastNavigationTime.current = now;
|
|
230
|
-
isInCooldown.current = true;
|
|
231
|
-
if (timeoutRef.current)
|
|
232
|
-
clearTimeout(timeoutRef.current);
|
|
233
|
-
onRequestIndexChange(navDelta);
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
element.addEventListener("wheel", onWheel, { passive: false });
|
|
237
|
-
return () => {
|
|
238
|
-
element.removeEventListener("wheel", onWheel);
|
|
239
|
-
if (timeoutRef.current)
|
|
240
|
-
clearTimeout(timeoutRef.current);
|
|
241
|
-
};
|
|
242
|
-
}, [
|
|
243
|
-
orientation,
|
|
244
|
-
direction,
|
|
245
|
-
discretePaging,
|
|
246
|
-
threshold,
|
|
247
|
-
cooldown,
|
|
248
|
-
onRequestIndexChange,
|
|
249
|
-
resetAccumulated,
|
|
250
|
-
viewport,
|
|
251
|
-
endGesture,
|
|
252
|
-
onDragStart,
|
|
253
|
-
onDrag
|
|
254
|
-
]);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// src/hooks/useKeyboard.ts
|
|
258
|
-
import { useCallback as useCallback3, useEffect as useEffect2 } from "react";
|
|
259
|
-
var DEFAULT_BINDINGS_VERTICAL = {
|
|
260
|
-
prev: ["ArrowUp"],
|
|
261
|
-
next: ["ArrowDown"],
|
|
262
|
-
first: ["Home"],
|
|
263
|
-
last: ["End"],
|
|
264
|
-
altPrev: ["PageUp"],
|
|
265
|
-
altNext: ["PageDown"]
|
|
266
|
-
};
|
|
267
|
-
var DEFAULT_BINDINGS_HORIZONTAL = {
|
|
268
|
-
prev: ["ArrowLeft"],
|
|
269
|
-
next: ["ArrowRight"],
|
|
270
|
-
first: ["Home"],
|
|
271
|
-
last: ["End"],
|
|
272
|
-
altPrev: ["PageUp"],
|
|
273
|
-
altNext: ["PageDown"]
|
|
274
|
-
};
|
|
275
|
-
function useKeyboard(params) {
|
|
276
|
-
const { orientation, direction, config, onPrev, onNext, onFirst, onLast } = params;
|
|
277
|
-
const enabled = config?.enabled ?? true;
|
|
278
|
-
const isGlobal = config?.global ?? false;
|
|
279
|
-
const bindings = config?.bindings ?? (orientation === "vertical" ? DEFAULT_BINDINGS_VERTICAL : DEFAULT_BINDINGS_HORIZONTAL);
|
|
280
|
-
const handleKeyDown = useCallback3((evt) => {
|
|
281
|
-
if (!enabled)
|
|
282
|
-
return;
|
|
283
|
-
const key = evt.key;
|
|
284
|
-
const prevKeys = [...bindings.prev ?? [], ...bindings.altPrev ?? []];
|
|
285
|
-
const nextKeys = [...bindings.next ?? [], ...bindings.altNext ?? []];
|
|
286
|
-
const isHorizontal = orientation === "horizontal";
|
|
287
|
-
const rtl = direction === "rtl";
|
|
288
|
-
if (prevKeys.includes(key)) {
|
|
289
|
-
evt.preventDefault();
|
|
290
|
-
if (isHorizontal && rtl)
|
|
291
|
-
onNext();
|
|
292
|
-
else
|
|
293
|
-
onPrev();
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
if (nextKeys.includes(key)) {
|
|
297
|
-
evt.preventDefault();
|
|
298
|
-
if (isHorizontal && rtl)
|
|
299
|
-
onPrev();
|
|
300
|
-
else
|
|
301
|
-
onNext();
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (bindings.first?.includes(key)) {
|
|
305
|
-
evt.preventDefault();
|
|
306
|
-
onFirst?.();
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (bindings.last?.includes(key)) {
|
|
310
|
-
evt.preventDefault();
|
|
311
|
-
onLast?.();
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
}, [bindings, direction, enabled, onFirst, onLast, onNext, onPrev, orientation]);
|
|
315
|
-
useEffect2(() => {
|
|
316
|
-
if (!enabled || !isGlobal)
|
|
317
|
-
return;
|
|
318
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
319
|
-
return () => {
|
|
320
|
-
window.removeEventListener("keydown", handleKeyDown);
|
|
321
|
-
};
|
|
322
|
-
}, [enabled, isGlobal, handleKeyDown]);
|
|
323
|
-
return { onKeyDown: handleKeyDown };
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// src/hooks/useVirtualizer.ts
|
|
327
|
-
import { useEffect as useEffect3, useLayoutEffect, useState as useState2, useMemo as useMemo2, useCallback as useCallback4 } from "react";
|
|
328
|
-
import { useVirtualizer as useTanStackVirtualizer } from "@tanstack/react-virtual";
|
|
329
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect3;
|
|
330
|
-
function useVirtualizer(params) {
|
|
331
|
-
const { items, virtual, getScrollElement, orientation = "vertical" } = params;
|
|
332
|
-
const count = items.length;
|
|
333
|
-
const [sizeState, setSizeState] = useState2(() => {
|
|
334
|
-
const fallback = typeof window !== "undefined" ? orientation === "vertical" ? window.innerHeight : window.innerWidth : 800;
|
|
335
|
-
return { size: fallback, measured: false };
|
|
336
|
-
});
|
|
337
|
-
useIsomorphicLayoutEffect(() => {
|
|
338
|
-
const scrollElement = getScrollElement();
|
|
339
|
-
if (!scrollElement)
|
|
340
|
-
return;
|
|
341
|
-
const updateSize = () => {
|
|
342
|
-
const size = orientation === "vertical" ? scrollElement.clientHeight : scrollElement.clientWidth;
|
|
343
|
-
if (size > 0) {
|
|
344
|
-
setSizeState((prev) => {
|
|
345
|
-
if (prev.size !== size || !prev.measured) {
|
|
346
|
-
return { size, measured: true };
|
|
347
|
-
}
|
|
348
|
-
return prev;
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
updateSize();
|
|
353
|
-
const resizeObserver = new ResizeObserver(updateSize);
|
|
354
|
-
resizeObserver.observe(scrollElement);
|
|
355
|
-
return () => {
|
|
356
|
-
resizeObserver.disconnect();
|
|
357
|
-
};
|
|
358
|
-
}, [getScrollElement, orientation]);
|
|
359
|
-
const measuredSize = sizeState.size;
|
|
360
|
-
const getEstimatedSize = useCallback4((i) => {
|
|
361
|
-
const explicitSize = virtual?.estimatedSize;
|
|
362
|
-
if (typeof explicitSize === "function") {
|
|
363
|
-
return explicitSize(items[i], i);
|
|
364
|
-
}
|
|
365
|
-
if (measuredSize > 0) {
|
|
366
|
-
return measuredSize;
|
|
367
|
-
}
|
|
368
|
-
return typeof explicitSize === "number" ? explicitSize : 800;
|
|
369
|
-
}, [virtual?.estimatedSize, items, measuredSize]);
|
|
370
|
-
const initialRect = useMemo2(() => {
|
|
371
|
-
if (typeof window === "undefined") {
|
|
372
|
-
return { width: 800, height: 800 };
|
|
373
|
-
}
|
|
374
|
-
return {
|
|
375
|
-
width: window.innerWidth,
|
|
376
|
-
height: window.innerHeight
|
|
377
|
-
};
|
|
378
|
-
}, []);
|
|
379
|
-
const getItemKey = useMemo2(() => {
|
|
380
|
-
if (!virtual?.getItemKey)
|
|
381
|
-
return;
|
|
382
|
-
return (index) => virtual.getItemKey?.(items[index], index) ?? index;
|
|
383
|
-
}, [virtual?.getItemKey, items]);
|
|
384
|
-
const rowVirtualizer = useTanStackVirtualizer({
|
|
385
|
-
count,
|
|
386
|
-
getScrollElement,
|
|
387
|
-
estimateSize: getEstimatedSize,
|
|
388
|
-
overscan: virtual?.overscan ?? 5,
|
|
389
|
-
horizontal: orientation === "horizontal",
|
|
390
|
-
getItemKey,
|
|
391
|
-
initialRect
|
|
392
|
-
});
|
|
393
|
-
return {
|
|
394
|
-
virtualItems: rowVirtualizer.getVirtualItems().map((item) => ({
|
|
395
|
-
index: item.index,
|
|
396
|
-
key: item.key,
|
|
397
|
-
offset: item.start,
|
|
398
|
-
size: item.size,
|
|
399
|
-
measureElement: rowVirtualizer.measureElement
|
|
400
|
-
})),
|
|
401
|
-
totalSize: rowVirtualizer.getTotalSize(),
|
|
402
|
-
getItemOffset: (index) => {
|
|
403
|
-
const found = rowVirtualizer.getVirtualItems().find((v) => v.index === index);
|
|
404
|
-
return found ? found.start : 0;
|
|
405
|
-
},
|
|
406
|
-
getItemSize: (index) => {
|
|
407
|
-
const found = rowVirtualizer.getVirtualItems().find((v) => v.index === index);
|
|
408
|
-
return found ? found.size : 0;
|
|
409
|
-
},
|
|
410
|
-
scrollToIndex: (index, options) => {
|
|
411
|
-
rowVirtualizer.scrollToIndex(index, {
|
|
412
|
-
align: options?.align,
|
|
413
|
-
behavior: options?.behavior
|
|
414
|
-
});
|
|
415
|
-
},
|
|
416
|
-
containerSize: measuredSize
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// src/hooks/useSwipeDeck.ts
|
|
421
|
-
var DEFAULTS = {
|
|
422
|
-
orientation: "vertical",
|
|
423
|
-
direction: "ltr",
|
|
424
|
-
loop: false,
|
|
425
|
-
defaultIndex: 0,
|
|
426
|
-
gesture: {
|
|
427
|
-
threshold: 10,
|
|
428
|
-
flickVelocity: 0.1,
|
|
429
|
-
lockAxis: true,
|
|
430
|
-
ignoreWhileAnimating: true
|
|
431
|
-
},
|
|
432
|
-
wheel: {
|
|
433
|
-
discretePaging: true,
|
|
434
|
-
threshold: 100,
|
|
435
|
-
debounce: 120,
|
|
436
|
-
cooldown: 800
|
|
437
|
-
},
|
|
438
|
-
keyboard: {
|
|
439
|
-
enabled: true
|
|
440
|
-
},
|
|
441
|
-
visibility: {
|
|
442
|
-
strategy: "position",
|
|
443
|
-
intersectionRatio: 0.6,
|
|
444
|
-
debounce: 100
|
|
445
|
-
},
|
|
446
|
-
virtual: {
|
|
447
|
-
overscan: 5
|
|
448
|
-
},
|
|
449
|
-
endReachedThreshold: 3,
|
|
450
|
-
ariaLabel: "Swipe feed",
|
|
451
|
-
keyboardNavigation: true
|
|
452
|
-
};
|
|
453
|
-
function useSwipeDeck(options) {
|
|
454
|
-
const items = options.items ?? [];
|
|
455
|
-
const orientation = options.orientation ?? DEFAULTS.orientation;
|
|
456
|
-
const direction = options.direction ?? DEFAULTS.direction;
|
|
457
|
-
const loop = options.loop ?? DEFAULTS.loop;
|
|
458
|
-
const defaultIndex = options.defaultIndex ?? DEFAULTS.defaultIndex;
|
|
459
|
-
const preload = options.preload ?? 0;
|
|
460
|
-
const gestureCfg = useMemo3(() => ({ ...DEFAULTS.gesture, ...options.gesture ?? {} }), [options.gesture]);
|
|
461
|
-
const wheelCfg = useMemo3(() => ({ ...DEFAULTS.wheel, ...options.wheel ?? {} }), [options.wheel]);
|
|
462
|
-
const keyboardCfg = useMemo3(() => ({ ...DEFAULTS.keyboard, ...options.keyboard ?? {} }), [options.keyboard]);
|
|
463
|
-
const virtualCfg = useMemo3(() => {
|
|
464
|
-
const base = { ...DEFAULTS.virtual, ...options.virtual ?? {} };
|
|
465
|
-
return {
|
|
466
|
-
...base,
|
|
467
|
-
overscan: Math.max(base.overscan ?? 0, preload)
|
|
468
|
-
};
|
|
469
|
-
}, [options.virtual, preload]);
|
|
470
|
-
const endReachedThreshold = options.endReachedThreshold ?? DEFAULTS.endReachedThreshold;
|
|
471
|
-
const ariaLabel = options.ariaLabel ?? DEFAULTS.ariaLabel;
|
|
472
|
-
const keyboardNavigation = options.keyboardNavigation ?? true;
|
|
473
|
-
const isControlled = typeof options.index === "number";
|
|
474
|
-
const [internalIndex, setInternalIndex] = useState3(() => clamp(defaultIndex, 0, Math.max(items.length - 1, 0)));
|
|
475
|
-
const index = isControlled ? clamp(options.index ?? 0, 0, Math.max(items.length - 1, 0)) : internalIndex;
|
|
476
|
-
const [isAnimating, setIsAnimating] = useState3(false);
|
|
477
|
-
const [viewport, setViewport] = useState3(null);
|
|
478
|
-
const sourceRef = useRef3("snap");
|
|
479
|
-
const dragStartScrollRef = useRef3(0);
|
|
480
|
-
const isNavigatingRef = useRef3(false);
|
|
481
|
-
useEffect4(() => {
|
|
482
|
-
const clamped = clamp(index, 0, Math.max(items.length - 1, 0));
|
|
483
|
-
if (!isControlled)
|
|
484
|
-
setInternalIndex(clamped);
|
|
485
|
-
}, [index, isControlled, items.length]);
|
|
486
|
-
const virtualizer = useVirtualizer({
|
|
487
|
-
items,
|
|
488
|
-
virtual: virtualCfg,
|
|
489
|
-
getScrollElement: useCallback5(() => viewport, [viewport]),
|
|
490
|
-
orientation
|
|
491
|
-
});
|
|
492
|
-
const latest = useRef3({
|
|
493
|
-
index,
|
|
494
|
-
items,
|
|
495
|
-
isControlled,
|
|
496
|
-
options,
|
|
497
|
-
virtualizer,
|
|
498
|
-
loop,
|
|
499
|
-
orientation,
|
|
500
|
-
setInternalIndex,
|
|
501
|
-
setIsAnimating,
|
|
502
|
-
viewport
|
|
503
|
-
});
|
|
504
|
-
latest.current = {
|
|
505
|
-
index,
|
|
506
|
-
items,
|
|
507
|
-
isControlled,
|
|
508
|
-
options,
|
|
509
|
-
virtualizer,
|
|
510
|
-
loop,
|
|
511
|
-
orientation,
|
|
512
|
-
setInternalIndex,
|
|
513
|
-
setIsAnimating,
|
|
514
|
-
viewport
|
|
515
|
-
};
|
|
516
|
-
const applyIndexChange = useCallback5((nextIndex) => {
|
|
517
|
-
const { index: index2, isControlled: isControlled2, options: options2, setInternalIndex: setInternalIndex2, setIsAnimating: setIsAnimating2 } = latest.current;
|
|
518
|
-
if (nextIndex === index2)
|
|
519
|
-
return;
|
|
520
|
-
if (!isControlled2)
|
|
521
|
-
setInternalIndex2(nextIndex);
|
|
522
|
-
options2.onIndexChange?.(nextIndex, sourceRef.current ?? "snap");
|
|
523
|
-
setIsAnimating2(false);
|
|
524
|
-
sourceRef.current = "snap";
|
|
525
|
-
}, []);
|
|
526
|
-
const navigateTo = useCallback5((targetIndex, source, behavior) => {
|
|
527
|
-
const { items: items2, loop: loop2, index: index2, isControlled: isControlled2, options: options2, orientation: orientation2, virtualizer: virtualizer2, setInternalIndex: setInternalIndex2, viewport: viewport2 } = latest.current;
|
|
528
|
-
if (items2.length === 0)
|
|
529
|
-
return;
|
|
530
|
-
const maxIndex = items2.length - 1;
|
|
531
|
-
let next2 = targetIndex;
|
|
532
|
-
if (loop2) {
|
|
533
|
-
next2 = (next2 + items2.length) % items2.length;
|
|
534
|
-
} else {
|
|
535
|
-
next2 = clamp(next2, 0, maxIndex);
|
|
536
|
-
}
|
|
537
|
-
if (next2 === index2 && source !== "snap")
|
|
538
|
-
return;
|
|
539
|
-
sourceRef.current = source;
|
|
540
|
-
isNavigatingRef.current = true;
|
|
541
|
-
if (!isControlled2)
|
|
542
|
-
setInternalIndex2(next2);
|
|
543
|
-
options2.onIndexChange?.(next2, source);
|
|
544
|
-
if (!viewport2)
|
|
545
|
-
return;
|
|
546
|
-
const originalSnapType = viewport2.style.scrollSnapType;
|
|
547
|
-
viewport2.style.scrollSnapType = "none";
|
|
548
|
-
viewport2.style.scrollBehavior = "auto";
|
|
549
|
-
const targetBehavior = behavior ?? (prefersReducedMotion() ? "instant" : "smooth");
|
|
550
|
-
const targetScroll = next2 * virtualizer2.containerSize;
|
|
551
|
-
if (orientation2 === "vertical") {
|
|
552
|
-
viewport2.scrollTo({ top: targetScroll, behavior: targetBehavior });
|
|
553
|
-
} else {
|
|
554
|
-
viewport2.scrollTo({ left: targetScroll, behavior: targetBehavior });
|
|
555
|
-
}
|
|
556
|
-
setTimeout(() => {
|
|
557
|
-
isNavigatingRef.current = false;
|
|
558
|
-
viewport2.style.scrollSnapType = originalSnapType || (orientation2 === "vertical" ? "y mandatory" : "x mandatory");
|
|
559
|
-
}, targetBehavior === "smooth" ? 600 : 50);
|
|
560
|
-
}, []);
|
|
561
|
-
const onDragStart = useCallback5(() => {
|
|
562
|
-
const { viewport: viewport2, orientation: orientation2 } = latest.current;
|
|
563
|
-
if (viewport2) {
|
|
564
|
-
viewport2.style.scrollBehavior = "auto";
|
|
565
|
-
dragStartScrollRef.current = orientation2 === "vertical" ? viewport2.scrollTop : viewport2.scrollLeft;
|
|
566
|
-
}
|
|
567
|
-
}, []);
|
|
568
|
-
const onDrag = useCallback5((delta) => {
|
|
569
|
-
const { viewport: viewport2, orientation: orientation2 } = latest.current;
|
|
570
|
-
if (viewport2) {
|
|
571
|
-
const newScroll = dragStartScrollRef.current - delta;
|
|
572
|
-
if (orientation2 === "vertical") {
|
|
573
|
-
viewport2.scrollTop = newScroll;
|
|
574
|
-
} else {
|
|
575
|
-
viewport2.scrollLeft = newScroll;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}, []);
|
|
579
|
-
const wheel = useWheel({
|
|
580
|
-
orientation,
|
|
581
|
-
direction,
|
|
582
|
-
discretePaging: wheelCfg.discretePaging ?? true,
|
|
583
|
-
threshold: wheelCfg.threshold ?? 80,
|
|
584
|
-
debounce: wheelCfg.debounce ?? 120,
|
|
585
|
-
cooldown: wheelCfg.cooldown ?? 400,
|
|
586
|
-
onRequestIndexChange: (delta) => navigateTo(latest.current.index + delta, "user:wheel"),
|
|
587
|
-
viewport,
|
|
588
|
-
onDragStart,
|
|
589
|
-
onDrag,
|
|
590
|
-
onDragEnd: () => navigateTo(latest.current.index, "snap")
|
|
591
|
-
});
|
|
592
|
-
const gestures = useGestures({
|
|
593
|
-
orientation,
|
|
594
|
-
direction,
|
|
595
|
-
threshold: gestureCfg.threshold ?? 50,
|
|
596
|
-
flickVelocity: gestureCfg.flickVelocity ?? 0.5,
|
|
597
|
-
lockAxis: gestureCfg.lockAxis ?? true,
|
|
598
|
-
ignoreWhileAnimating: gestureCfg.ignoreWhileAnimating ?? true,
|
|
599
|
-
loop,
|
|
600
|
-
getIndex: () => latest.current.index,
|
|
601
|
-
maxIndex: Math.max(items.length - 1, 0),
|
|
602
|
-
onRequestIndexChange: (next2) => navigateTo(next2, "user:gesture"),
|
|
603
|
-
setAnimating: setIsAnimating,
|
|
604
|
-
isAnimating,
|
|
605
|
-
onDragStart,
|
|
606
|
-
onDrag
|
|
607
|
-
});
|
|
608
|
-
const keyboard = useKeyboard({
|
|
609
|
-
orientation,
|
|
610
|
-
direction,
|
|
611
|
-
config: keyboardNavigation ? keyboardCfg : { enabled: false },
|
|
612
|
-
onPrev: () => navigateTo(latest.current.index - 1, "user:keyboard"),
|
|
613
|
-
onNext: () => navigateTo(latest.current.index + 1, "user:keyboard"),
|
|
614
|
-
onFirst: () => navigateTo(0, "user:keyboard"),
|
|
615
|
-
onLast: () => navigateTo(items.length - 1, "user:keyboard")
|
|
616
|
-
});
|
|
617
|
-
const rafId = useRef3(null);
|
|
618
|
-
const scrollEndTimeoutRef = useRef3(null);
|
|
619
|
-
const handleScroll = useCallback5(() => {
|
|
620
|
-
if (isNavigatingRef.current)
|
|
621
|
-
return;
|
|
622
|
-
if (scrollEndTimeoutRef.current)
|
|
623
|
-
clearTimeout(scrollEndTimeoutRef.current);
|
|
624
|
-
scrollEndTimeoutRef.current = setTimeout(() => {
|
|
625
|
-
if (isNavigatingRef.current)
|
|
626
|
-
return;
|
|
627
|
-
const { viewport: viewport2, orientation: orientation2, index: index2 } = latest.current;
|
|
628
|
-
if (!viewport2)
|
|
629
|
-
return;
|
|
630
|
-
const scrollOffset = orientation2 === "vertical" ? viewport2.scrollTop : viewport2.scrollLeft;
|
|
631
|
-
const computedSize = orientation2 === "vertical" ? viewport2.clientHeight : viewport2.clientWidth;
|
|
632
|
-
const idealOffset = index2 * computedSize;
|
|
633
|
-
if (Math.abs(scrollOffset - idealOffset) > 2) {
|
|
634
|
-
viewport2.scrollTo({
|
|
635
|
-
top: orientation2 === "vertical" ? idealOffset : 0,
|
|
636
|
-
left: orientation2 === "horizontal" ? idealOffset : 0,
|
|
637
|
-
behavior: "smooth"
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
}, 150);
|
|
641
|
-
if (rafId.current !== null)
|
|
642
|
-
return;
|
|
643
|
-
rafId.current = requestAnimationFrame(() => {
|
|
644
|
-
rafId.current = null;
|
|
645
|
-
if (isNavigatingRef.current)
|
|
646
|
-
return;
|
|
647
|
-
const { viewport: viewport2, orientation: orientation2, items: items2 } = latest.current;
|
|
648
|
-
if (!viewport2)
|
|
649
|
-
return;
|
|
650
|
-
const scrollOffset = orientation2 === "vertical" ? viewport2.scrollTop : viewport2.scrollLeft;
|
|
651
|
-
const viewportSize = orientation2 === "vertical" ? viewport2.clientHeight : viewport2.clientWidth;
|
|
652
|
-
if (viewportSize > 0 && items2.length > 0) {
|
|
653
|
-
const estimatedIndex = Math.round(scrollOffset / viewportSize);
|
|
654
|
-
const newIndex = clamp(estimatedIndex, 0, items2.length - 1);
|
|
655
|
-
applyIndexChange(newIndex);
|
|
656
|
-
}
|
|
657
|
-
});
|
|
658
|
-
}, [applyIndexChange]);
|
|
659
|
-
useEffect4(() => {
|
|
660
|
-
if (items.length === 0)
|
|
661
|
-
return;
|
|
662
|
-
const maxIndex = items.length - 1;
|
|
663
|
-
const distanceFromEnd = maxIndex - index;
|
|
664
|
-
if (distanceFromEnd <= endReachedThreshold) {
|
|
665
|
-
options.onEndReached?.({ distanceFromEnd, direction: "forward" });
|
|
666
|
-
}
|
|
667
|
-
if (index <= endReachedThreshold) {
|
|
668
|
-
options.onEndReached?.({ distanceFromEnd: index, direction: "backward" });
|
|
669
|
-
}
|
|
670
|
-
}, [endReachedThreshold, index, items.length, options]);
|
|
671
|
-
const scrollBehavior = useMemo3(() => prefersReducedMotion() ? "instant" : "smooth", []);
|
|
672
|
-
const scrollTo = useCallback5((target, opts) => {
|
|
673
|
-
navigateTo(target, "programmatic", opts?.behavior ?? scrollBehavior);
|
|
674
|
-
}, [navigateTo, scrollBehavior]);
|
|
675
|
-
const apiState = useMemo3(() => ({
|
|
676
|
-
index,
|
|
677
|
-
isAnimating,
|
|
678
|
-
canPrev: loop || index > 0,
|
|
679
|
-
canNext: loop || index < items.length - 1
|
|
680
|
-
}), [index, isAnimating, items.length, loop]);
|
|
681
|
-
const resizeTimeoutRef = useRef3(null);
|
|
682
|
-
useEffect4(() => {
|
|
683
|
-
if (!viewport)
|
|
684
|
-
return;
|
|
685
|
-
const handleResize = () => {
|
|
686
|
-
if (resizeTimeoutRef.current) {
|
|
687
|
-
clearTimeout(resizeTimeoutRef.current);
|
|
688
|
-
}
|
|
689
|
-
resizeTimeoutRef.current = setTimeout(() => {
|
|
690
|
-
const { orientation: orientation2, index: currentIndex } = latest.current;
|
|
691
|
-
if (!viewport)
|
|
692
|
-
return;
|
|
693
|
-
const size = orientation2 === "vertical" ? viewport.clientHeight : viewport.clientWidth;
|
|
694
|
-
const targetScroll = currentIndex * size;
|
|
695
|
-
const currentScroll = orientation2 === "vertical" ? viewport.scrollTop : viewport.scrollLeft;
|
|
696
|
-
if (Math.abs(currentScroll - targetScroll) > size * 0.1) {
|
|
697
|
-
if (orientation2 === "vertical") {
|
|
698
|
-
viewport.scrollTop = targetScroll;
|
|
699
|
-
} else {
|
|
700
|
-
viewport.scrollLeft = targetScroll;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}, 50);
|
|
704
|
-
};
|
|
705
|
-
const resizeObserver = new ResizeObserver(handleResize);
|
|
706
|
-
resizeObserver.observe(viewport);
|
|
707
|
-
return () => {
|
|
708
|
-
resizeObserver.disconnect();
|
|
709
|
-
if (resizeTimeoutRef.current) {
|
|
710
|
-
clearTimeout(resizeTimeoutRef.current);
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
}, [viewport]);
|
|
714
|
-
const handleTouchStart = useCallback5(() => {
|
|
715
|
-
const { viewport: viewport2, orientation: orientation2 } = latest.current;
|
|
716
|
-
if (viewport2) {
|
|
717
|
-
viewport2.style.scrollSnapType = orientation2 === "vertical" ? "y mandatory" : "x mandatory";
|
|
718
|
-
}
|
|
719
|
-
}, []);
|
|
720
|
-
const getViewportProps = useCallback5(() => {
|
|
721
|
-
const virtualStyles = {
|
|
722
|
-
position: "relative",
|
|
723
|
-
overflow: "auto",
|
|
724
|
-
scrollSnapType: orientation === "vertical" ? "y mandatory" : "x mandatory",
|
|
725
|
-
touchAction: orientation === "vertical" ? "pan-y" : "pan-x",
|
|
726
|
-
willChange: "scroll-position"
|
|
727
|
-
};
|
|
728
|
-
return {
|
|
729
|
-
ref: setViewport,
|
|
730
|
-
role: "feed",
|
|
731
|
-
"aria-label": ariaLabel,
|
|
732
|
-
"aria-busy": isAnimating,
|
|
733
|
-
tabIndex: 0,
|
|
734
|
-
onScroll: handleScroll,
|
|
735
|
-
onKeyDown: keyboard.onKeyDown,
|
|
736
|
-
onTouchStart: handleTouchStart,
|
|
737
|
-
...gestures.handlers,
|
|
738
|
-
style: virtualStyles
|
|
739
|
-
};
|
|
740
|
-
}, [ariaLabel, handleScroll, handleTouchStart, isAnimating, keyboard.onKeyDown, orientation, gestures.handlers]);
|
|
741
|
-
const getItemProps = useCallback5((itemIndex) => {
|
|
742
|
-
const isActive = index === itemIndex;
|
|
743
|
-
const sizeUnit = orientation === "vertical" ? "100dvh" : "100dvw";
|
|
744
|
-
return {
|
|
745
|
-
ref: undefined,
|
|
746
|
-
"data-index": itemIndex,
|
|
747
|
-
"data-active": isActive,
|
|
748
|
-
style: {
|
|
749
|
-
position: "absolute",
|
|
750
|
-
top: 0,
|
|
751
|
-
left: 0,
|
|
752
|
-
transform: orientation === "vertical" ? `translateY(calc(${itemIndex} * ${sizeUnit}))` : `translateX(calc(${itemIndex} * ${sizeUnit}))`,
|
|
753
|
-
height: orientation === "vertical" ? sizeUnit : "100%",
|
|
754
|
-
width: orientation === "horizontal" ? sizeUnit : "100%",
|
|
755
|
-
willChange: "transform",
|
|
756
|
-
scrollSnapAlign: "start",
|
|
757
|
-
scrollSnapStop: "always"
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
}, [index, orientation]);
|
|
761
|
-
const prev = useCallback5(() => navigateTo(latest.current.index - 1, "user:keyboard"), [navigateTo]);
|
|
762
|
-
const next = useCallback5(() => navigateTo(latest.current.index + 1, "user:keyboard"), [navigateTo]);
|
|
763
|
-
const api = useMemo3(() => ({
|
|
764
|
-
...apiState,
|
|
765
|
-
prev,
|
|
766
|
-
next,
|
|
767
|
-
scrollTo: (target, opts) => navigateTo(target, "programmatic", opts?.behavior),
|
|
768
|
-
getViewportProps,
|
|
769
|
-
getItemProps,
|
|
770
|
-
virtualItems: virtualizer.virtualItems,
|
|
771
|
-
totalSize: virtualizer.totalSize,
|
|
772
|
-
items,
|
|
773
|
-
orientation,
|
|
774
|
-
viewport
|
|
775
|
-
}), [apiState, prev, next, navigateTo, getViewportProps, getItemProps, virtualizer.virtualItems, virtualizer.totalSize, items, orientation, viewport]);
|
|
776
|
-
return api;
|
|
777
|
-
}
|
|
778
|
-
// src/hooks/useWindowSize.ts
|
|
779
|
-
import { useState as useState4, useEffect as useEffect5 } from "react";
|
|
780
|
-
function useWindowSize() {
|
|
781
|
-
const [size, setSize] = useState4({
|
|
782
|
-
width: typeof window !== "undefined" ? window.innerWidth : 0,
|
|
783
|
-
height: typeof window !== "undefined" ? window.innerHeight : 0
|
|
784
|
-
});
|
|
785
|
-
useEffect5(() => {
|
|
786
|
-
if (typeof window === "undefined")
|
|
787
|
-
return;
|
|
788
|
-
let timeoutId;
|
|
789
|
-
const handleResize = () => {
|
|
790
|
-
clearTimeout(timeoutId);
|
|
791
|
-
timeoutId = setTimeout(() => {
|
|
792
|
-
setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
793
|
-
}, 100);
|
|
794
|
-
};
|
|
795
|
-
window.addEventListener("resize", handleResize);
|
|
796
|
-
return () => {
|
|
797
|
-
window.removeEventListener("resize", handleResize);
|
|
798
|
-
clearTimeout(timeoutId);
|
|
799
|
-
};
|
|
800
|
-
}, []);
|
|
801
|
-
return size;
|
|
802
|
-
}
|
|
803
|
-
// src/hooks/useSwipeItem.ts
|
|
804
|
-
import { createContext, useContext } from "react";
|
|
805
|
-
var SwipeItemContext = createContext(undefined);
|
|
806
|
-
function useSwipeItem() {
|
|
807
|
-
const context = useContext(SwipeItemContext);
|
|
808
|
-
if (!context) {
|
|
809
|
-
throw new Error("useSwipeItem must be used within a SwipeDeck item");
|
|
810
|
-
}
|
|
811
|
-
return context;
|
|
812
|
-
}
|
|
813
|
-
// src/components/SwipeDeck.tsx
|
|
814
|
-
import { useImperativeHandle, useMemo as useMemo4 } from "react";
|
|
815
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
816
|
-
function SwipeDeck(props) {
|
|
817
|
-
const {
|
|
818
|
-
as: As = "div",
|
|
819
|
-
children,
|
|
820
|
-
className,
|
|
821
|
-
style,
|
|
822
|
-
ref,
|
|
823
|
-
...options
|
|
824
|
-
} = props;
|
|
825
|
-
const deck = useSwipeDeck(options);
|
|
826
|
-
useImperativeHandle(ref, () => ({
|
|
827
|
-
prev: deck.prev,
|
|
828
|
-
next: deck.next,
|
|
829
|
-
scrollTo: deck.scrollTo,
|
|
830
|
-
getState: () => ({
|
|
831
|
-
index: deck.index,
|
|
832
|
-
isAnimating: deck.isAnimating,
|
|
833
|
-
canPrev: deck.canPrev,
|
|
834
|
-
canNext: deck.canNext
|
|
835
|
-
}),
|
|
836
|
-
viewport: deck.viewport
|
|
837
|
-
}), [deck]);
|
|
838
|
-
const { style: virtualStyle, ...restViewportProps } = deck.getViewportProps();
|
|
839
|
-
const fullscreenStyle = props.fullscreen ? {
|
|
840
|
-
height: "100dvh",
|
|
841
|
-
width: "100%",
|
|
842
|
-
position: "absolute",
|
|
843
|
-
top: 0,
|
|
844
|
-
left: 0
|
|
845
|
-
} : {};
|
|
846
|
-
const viewportStyle = useMemo4(() => ({ ...virtualStyle, ...fullscreenStyle, ...style }), [virtualStyle, fullscreenStyle, style]);
|
|
847
|
-
const contentStyle = useMemo4(() => ({
|
|
848
|
-
height: deck.orientation === "vertical" ? `calc(${deck.items.length} * 100dvh)` : "100%",
|
|
849
|
-
width: deck.orientation === "horizontal" ? `calc(${deck.items.length} * 100dvw)` : "100%",
|
|
850
|
-
position: "relative"
|
|
851
|
-
}), [deck.orientation, deck.items.length]);
|
|
852
|
-
const Comp = As;
|
|
853
|
-
return /* @__PURE__ */ jsxDEV(Comp, {
|
|
854
|
-
...restViewportProps,
|
|
855
|
-
className,
|
|
856
|
-
style: viewportStyle,
|
|
857
|
-
children: /* @__PURE__ */ jsxDEV("div", {
|
|
858
|
-
style: contentStyle,
|
|
859
|
-
children: deck.items.map((item, itemIndex) => {
|
|
860
|
-
const itemProps = deck.getItemProps(itemIndex);
|
|
861
|
-
const preload = options.preload ?? 0;
|
|
862
|
-
const preloadPrevious = options.preloadPrevious ?? 0;
|
|
863
|
-
let shouldPreload = false;
|
|
864
|
-
if (preload > 0 || preloadPrevious > 0) {
|
|
865
|
-
const currentIndex = deck.index;
|
|
866
|
-
if (!options.loop) {
|
|
867
|
-
const isNext = itemIndex > currentIndex && itemIndex <= currentIndex + preload;
|
|
868
|
-
const isPrev = itemIndex < currentIndex && itemIndex >= currentIndex - preloadPrevious;
|
|
869
|
-
shouldPreload = isNext || isPrev;
|
|
870
|
-
} else {
|
|
871
|
-
const len = deck.items.length;
|
|
872
|
-
const forwardDist = (itemIndex - currentIndex + len) % len;
|
|
873
|
-
const backwardDist = (currentIndex - itemIndex + len) % len;
|
|
874
|
-
const isNext = forwardDist > 0 && forwardDist <= preload;
|
|
875
|
-
const isPrev = backwardDist > 0 && backwardDist <= preloadPrevious;
|
|
876
|
-
shouldPreload = isNext || isPrev;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
const contextValue = {
|
|
880
|
-
item,
|
|
881
|
-
index: itemIndex,
|
|
882
|
-
isActive: deck.index === itemIndex,
|
|
883
|
-
shouldPreload,
|
|
884
|
-
props: itemProps
|
|
885
|
-
};
|
|
886
|
-
const itemKey = options.virtual?.getItemKey?.(item, itemIndex) ?? itemIndex;
|
|
887
|
-
return /* @__PURE__ */ jsxDEV("article", {
|
|
888
|
-
...itemProps,
|
|
889
|
-
"aria-label": `Item ${itemIndex + 1} of ${deck.items.length}`,
|
|
890
|
-
children: /* @__PURE__ */ jsxDEV(SwipeItemContext.Provider, {
|
|
891
|
-
value: contextValue,
|
|
892
|
-
children: children(contextValue)
|
|
893
|
-
}, undefined, false, undefined, this)
|
|
894
|
-
}, itemKey, false, undefined, this);
|
|
895
|
-
})
|
|
896
|
-
}, undefined, false, undefined, this)
|
|
897
|
-
}, undefined, false, undefined, this);
|
|
898
|
-
}
|
|
899
|
-
export {
|
|
900
|
-
useWindowSize,
|
|
901
|
-
useSwipeItem,
|
|
902
|
-
useSwipeDeck,
|
|
903
|
-
SwipeDeck
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
//# debugId=081A8E066DB65B9364756E2164756E21
|
|
3
|
+
//# debugId=9F0C3AACC03F3E5E64756E2164756E21
|
|
907
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hooks/useSwipeDeck.ts", "../src/utils/clamp.ts", "../src/utils/prefersReducedMotion.ts", "../src/hooks/useGestures.ts", "../src/hooks/useWheel.ts", "../src/hooks/useKeyboard.ts", "../src/hooks/useVirtualizer.ts", "../src/hooks/useWindowSize.ts", "../src/hooks/useSwipeItem.ts", "../src/components/SwipeDeck.tsx"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type React from \"react\";\nimport { clamp } from \"../utils/clamp\";\nimport { prefersReducedMotion } from \"../utils/prefersReducedMotion\";\nimport { useGestures } from \"./useGestures\";\nimport { useWheel } from \"./useWheel\";\nimport { useKeyboard } from \"./useKeyboard\";\nimport { useVirtualizer } from \"./useVirtualizer\";\nimport type {\n Direction,\n IndexChangeSource,\n Orientation,\n ScrollBehavior,\n SwipeDeckAPI,\n SwipeDeckOptions,\n SwipeDeckState,\n} from \"../types\";\n\nconst DEFAULTS = {\n orientation: \"vertical\" as Orientation,\n direction: \"ltr\" as Direction,\n loop: false,\n defaultIndex: 0,\n gesture: {\n threshold: 10,\n flickVelocity: 0.1,\n lockAxis: true,\n ignoreWhileAnimating: true,\n },\n wheel: {\n discretePaging: true,\n threshold: 100,\n debounce: 120,\n cooldown: 800,\n },\n keyboard: {\n enabled: true,\n },\n visibility: {\n strategy: \"position\" as const,\n intersectionRatio: 0.6,\n debounce: 100,\n },\n virtual: {\n overscan: 5,\n },\n endReachedThreshold: 3,\n ariaLabel: \"Swipe feed\",\n keyboardNavigation: true,\n};\n\nexport function useSwipeDeck<T>(options: SwipeDeckOptions<T>): SwipeDeckAPI<T> {\n const items = options.items ?? [];\n const orientation = options.orientation ?? DEFAULTS.orientation;\n const direction = options.direction ?? DEFAULTS.direction;\n const loop = options.loop ?? DEFAULTS.loop;\n const defaultIndex = options.defaultIndex ?? DEFAULTS.defaultIndex;\n const preload = options.preload ?? 0;\n\n const gestureCfg = useMemo(() => ({ ...DEFAULTS.gesture, ...(options.gesture ?? {}) }), [options.gesture]);\n const wheelCfg = useMemo(() => ({ ...DEFAULTS.wheel, ...(options.wheel ?? {}) }), [options.wheel]);\n const keyboardCfg = useMemo(() => ({ ...DEFAULTS.keyboard, ...(options.keyboard ?? {}) }), [options.keyboard]);\n const virtualCfg = useMemo(() => {\n const base = { ...DEFAULTS.virtual, ...(options.virtual ?? {}) };\n // Ensure overscan is at least as large as preload to ensure preloaded items are rendered\n return {\n ...base,\n overscan: Math.max(base.overscan ?? 0, preload),\n };\n }, [options.virtual, preload]);\n const endReachedThreshold = options.endReachedThreshold ?? DEFAULTS.endReachedThreshold;\n const ariaLabel = options.ariaLabel ?? DEFAULTS.ariaLabel;\n const keyboardNavigation = options.keyboardNavigation ?? true;\n\n const isControlled = typeof options.index === \"number\";\n const [internalIndex, setInternalIndex] = useState(() => clamp(defaultIndex, 0, Math.max(items.length - 1, 0)));\n const index = isControlled ? clamp(options.index ?? 0, 0, Math.max(items.length - 1, 0)) : internalIndex;\n\n const [isAnimating, setIsAnimating] = useState(false);\n\n // Use state for viewport to ensure hooks like useVirtualizer/useWheel know when it's ready\n const [viewport, setViewport] = useState<HTMLElement | null>(null);\n\n const sourceRef = useRef<IndexChangeSource>(\"snap\");\n const dragStartScrollRef = useRef<number>(0);\n const isNavigatingRef = useRef(false); // Track programmatic navigation to prevent scroll handler interference\n\n useEffect(() => {\n // Clamp index when items change\n const clamped = clamp(index, 0, Math.max(items.length - 1, 0));\n if (!isControlled) setInternalIndex(clamped);\n }, [index, isControlled, items.length]);\n\n const virtualizer = useVirtualizer({\n items,\n virtual: virtualCfg,\n getScrollElement: useCallback(() => viewport, [viewport]),\n orientation,\n });\n\n // Stabilize callbacks using a ref for latest state\n const latest = useRef({\n index,\n items,\n isControlled,\n options,\n virtualizer,\n loop,\n orientation,\n setInternalIndex,\n setIsAnimating,\n viewport, // Add viewport to latest ref\n });\n\n // Update ref on every render\n latest.current = {\n index,\n items,\n isControlled,\n options,\n virtualizer,\n loop,\n orientation,\n setInternalIndex,\n setIsAnimating,\n viewport,\n };\n\n const applyIndexChange = useCallback(\n (nextIndex: number) => {\n const { index, isControlled, options, setInternalIndex, setIsAnimating } = latest.current;\n if (nextIndex === index) return;\n if (!isControlled) setInternalIndex(nextIndex);\n options.onIndexChange?.(nextIndex, sourceRef.current ?? \"snap\");\n setIsAnimating(false);\n sourceRef.current = \"snap\";\n },\n []\n );\n\n\n const navigateTo = useCallback(\n (targetIndex: number, source: IndexChangeSource, behavior?: ScrollBehavior) => {\n const { items, loop, index, isControlled, options, orientation, virtualizer, setInternalIndex, viewport } = latest.current;\n\n if (items.length === 0) return;\n const maxIndex = items.length - 1;\n let next = targetIndex;\n if (loop) {\n next = (next + items.length) % items.length;\n } else {\n next = clamp(next, 0, maxIndex);\n }\n\n // Don't navigate to same index unless it's a snap/correction\n if (next === index && source !== \"snap\") return;\n\n sourceRef.current = source;\n\n // Mark as navigating to prevent handleScroll from interfering\n isNavigatingRef.current = true;\n\n // Update index immediately\n if (!isControlled) setInternalIndex(next);\n options.onIndexChange?.(next, source);\n\n if (!viewport) return;\n\n // CRITICAL: Temporarily disable scroll-snap during programmatic navigation\n // This prevents CSS from fighting with our scroll position, while allowing\n // use to use smooth scrolling\n const originalSnapType = viewport.style.scrollSnapType;\n viewport.style.scrollSnapType = 'none';\n viewport.style.scrollBehavior = 'auto'; // Let virtualizer handle behavior\n\n const targetBehavior = behavior ?? (prefersReducedMotion() ? \"instant\" : \"smooth\");\n\n // Manual scroll calculation to bypass virtualizer's dynamic size check which warns on smooth scroll\n const targetScroll = next * virtualizer.containerSize;\n\n if (orientation === 'vertical') {\n viewport.scrollTo({ top: targetScroll, behavior: targetBehavior });\n } else {\n viewport.scrollTo({ left: targetScroll, behavior: targetBehavior });\n }\n\n // Re-enable scroll-snap after animation completes to lock it in\n // 600ms is usually enough for smooth scroll to finish\n setTimeout(() => {\n isNavigatingRef.current = false;\n viewport.style.scrollSnapType = originalSnapType || (orientation === 'vertical' ? 'y mandatory' : 'x mandatory');\n\n // Ensure we are perfectly snapped if the animation didn't land exactly \n // (though virtualizer usually nails it)\n }, targetBehavior === 'smooth' ? 600 : 50);\n },\n []\n );\n\n const onDragStart = useCallback(() => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n // Optimization: Force auto behavior immediately on drag start\n viewport.style.scrollBehavior = 'auto';\n dragStartScrollRef.current = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n }\n }, []);\n\n const onDrag = useCallback((delta: number) => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n const newScroll = dragStartScrollRef.current - delta;\n if (orientation === \"vertical\") {\n viewport.scrollTop = newScroll;\n } else {\n viewport.scrollLeft = newScroll;\n }\n // Force immediate scroll handling for smooth drag\n }\n }, []);\n\n const wheel = useWheel({\n orientation,\n direction,\n discretePaging: wheelCfg.discretePaging ?? true,\n threshold: wheelCfg.threshold ?? 80,\n debounce: wheelCfg.debounce ?? 120,\n cooldown: wheelCfg.cooldown ?? 400,\n onRequestIndexChange: delta => navigateTo(latest.current.index + delta, \"user:wheel\"),\n viewport,\n onDragStart,\n onDrag,\n onDragEnd: () => navigateTo(latest.current.index, \"snap\"),\n });\n\n const gestures = useGestures({\n orientation,\n direction,\n threshold: gestureCfg.threshold ?? 50,\n flickVelocity: gestureCfg.flickVelocity ?? 0.5,\n lockAxis: gestureCfg.lockAxis ?? true,\n ignoreWhileAnimating: gestureCfg.ignoreWhileAnimating ?? true,\n loop,\n getIndex: () => latest.current.index,\n maxIndex: Math.max(items.length - 1, 0),\n onRequestIndexChange: next => navigateTo(next, \"user:gesture\"),\n setAnimating: setIsAnimating,\n isAnimating,\n onDragStart,\n onDrag,\n });\n\n const keyboard = useKeyboard({\n orientation,\n direction,\n config: keyboardNavigation ? keyboardCfg : { enabled: false },\n onPrev: () => navigateTo(latest.current.index - 1, \"user:keyboard\"),\n onNext: () => navigateTo(latest.current.index + 1, \"user:keyboard\"),\n onFirst: () => navigateTo(0, \"user:keyboard\"),\n onLast: () => navigateTo(items.length - 1, \"user:keyboard\"),\n });\n\n // Calculate visibility based on scroll\n const rafId = useRef<number | null>(null);\n const scrollEndTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleScroll = useCallback(() => {\n // Skip scroll-based index calculation during programmatic navigation\n if (isNavigatingRef.current) return;\n\n // Safety Snap: If scrolling stops and we are misaligned, snap to current index\n if (scrollEndTimeoutRef.current) clearTimeout(scrollEndTimeoutRef.current);\n scrollEndTimeoutRef.current = setTimeout(() => {\n if (isNavigatingRef.current) return;\n const { viewport, orientation, index } = latest.current;\n if (!viewport) return;\n\n const scrollOffset = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n const computedSize = orientation === \"vertical\" ? viewport.clientHeight : viewport.clientWidth;\n const idealOffset = index * computedSize;\n\n if (Math.abs(scrollOffset - idealOffset) > 2) {\n // We are stuck between frames. Snap to the current detected index.\n viewport.scrollTo({\n top: orientation === \"vertical\" ? idealOffset : 0,\n left: orientation === \"horizontal\" ? idealOffset : 0,\n behavior: 'smooth'\n });\n }\n }, 150); // 150ms debounce for \"scroll end\"\n\n if (rafId.current !== null) return;\n\n rafId.current = requestAnimationFrame(() => {\n rafId.current = null;\n\n // Double-check we're not navigating\n if (isNavigatingRef.current) return;\n\n const { viewport, orientation, items } = latest.current;\n if (!viewport) return;\n\n const scrollOffset = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n const viewportSize = orientation === \"vertical\" ? viewport.clientHeight : viewport.clientWidth;\n\n // Simple geometric calculation - works with CSS viewport units\n // Each item is 100dvh tall, so index = scrollOffset / viewportSize\n if (viewportSize > 0 && items.length > 0) {\n const estimatedIndex = Math.round(scrollOffset / viewportSize);\n const newIndex = clamp(estimatedIndex, 0, items.length - 1);\n applyIndexChange(newIndex);\n }\n });\n }, [applyIndexChange]); // applyIndexChange is stable now\n\n // onEndReached\n useEffect(() => {\n if (items.length === 0) return;\n const maxIndex = items.length - 1;\n const distanceFromEnd = maxIndex - index;\n if (distanceFromEnd <= endReachedThreshold) {\n options.onEndReached?.({ distanceFromEnd, direction: \"forward\" });\n }\n if (index <= endReachedThreshold) {\n options.onEndReached?.({ distanceFromEnd: index, direction: \"backward\" });\n }\n }, [endReachedThreshold, index, items.length, options]);\n\n const scrollBehavior = useMemo(\n () => (prefersReducedMotion() ? \"instant\" : \"smooth\"),\n [],\n );\n\n const scrollTo = useCallback(\n (target: number, opts?: { behavior?: ScrollBehavior }) => {\n navigateTo(target, \"programmatic\", opts?.behavior ?? scrollBehavior);\n },\n [navigateTo, scrollBehavior],\n );\n\n const apiState: SwipeDeckState = useMemo(\n () => ({\n index,\n isAnimating,\n canPrev: loop || index > 0,\n canNext: loop || index < items.length - 1,\n }),\n [index, isAnimating, items.length, loop],\n );\n\n // ═══════════════════════════════════════════════════════════════════════════\n // RESIZE HANDLING: Scroll Position Correction\n // ═══════════════════════════════════════════════════════════════════════════\n // CSS viewport units handle item sizing automatically.\n // But scroll position (in pixels) becomes invalid on resize.\n // We use the current index state to correct scroll position after resize settles.\n const resizeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (!viewport) return;\n\n const handleResize = () => {\n // Clear any pending correction\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n\n // After resize settles, snap scroll to current index\n resizeTimeoutRef.current = setTimeout(() => {\n const { orientation, index: currentIndex } = latest.current;\n if (!viewport) return;\n\n const size = orientation === 'vertical' ? viewport.clientHeight : viewport.clientWidth;\n const targetScroll = currentIndex * size;\n\n // Only correct if significantly off (avoid fighting with scroll-snap)\n const currentScroll = orientation === 'vertical' ? viewport.scrollTop : viewport.scrollLeft;\n if (Math.abs(currentScroll - targetScroll) > size * 0.1) {\n if (orientation === 'vertical') {\n viewport.scrollTop = targetScroll;\n } else {\n viewport.scrollLeft = targetScroll;\n }\n }\n }, 50);\n };\n\n const resizeObserver = new ResizeObserver(handleResize);\n resizeObserver.observe(viewport);\n\n return () => {\n resizeObserver.disconnect();\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n };\n }, [viewport]);\n\n // Re-enable scroll-snap when user touches the screen\n const handleTouchStart = useCallback(() => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n viewport.style.scrollSnapType = orientation === 'vertical' ? 'y mandatory' : 'x mandatory';\n }\n }, []);\n\n const getViewportProps = useCallback(() => {\n const virtualStyles: React.CSSProperties = {\n position: \"relative\",\n overflow: \"auto\",\n // Native Scroll Snap - handles touch swipe automatically\n scrollSnapType: orientation === \"vertical\" ? \"y mandatory\" : \"x mandatory\",\n // Allow native touch scrolling - this works with scroll-snap for smooth swipe experience\n touchAction: orientation === \"vertical\" ? \"pan-y\" : \"pan-x\",\n willChange: \"scroll-position\",\n };\n\n return {\n ref: setViewport,\n role: \"feed\",\n \"aria-label\": ariaLabel,\n \"aria-busy\": isAnimating,\n tabIndex: 0,\n onScroll: handleScroll,\n // onWheel: wheel.onWheel, // REMOVED: Managed internally by useWheel\n onKeyDown: keyboard.onKeyDown,\n onTouchStart: handleTouchStart,\n ...gestures.handlers,\n style: virtualStyles,\n } satisfies React.HTMLAttributes<HTMLElement> & { ref: React.RefCallback<HTMLElement> };\n }, [ariaLabel, handleScroll, handleTouchStart, isAnimating, keyboard.onKeyDown, orientation, gestures.handlers]);\n\n const getItemProps = useCallback(\n (itemIndex: number) => {\n const isActive = index === itemIndex;\n\n // Use CSS viewport units for positioning - these automatically update on rotation!\n // This is much simpler and more reliable than trying to correct pixel offsets.\n const sizeUnit = orientation === 'vertical' ? '100dvh' : '100dvw';\n\n return {\n ref: undefined,\n \"data-index\": itemIndex,\n \"data-active\": isActive,\n style: {\n position: \"absolute\" as const,\n top: 0,\n left: 0,\n // Use CSS calc with viewport units - browser handles rotation automatically!\n transform: orientation === 'vertical'\n ? `translateY(calc(${itemIndex} * ${sizeUnit}))`\n : `translateX(calc(${itemIndex} * ${sizeUnit}))`,\n height: orientation === 'vertical' ? sizeUnit : '100%',\n width: orientation === 'horizontal' ? sizeUnit : '100%',\n willChange: \"transform\",\n // Native Snap Item Styles\n scrollSnapAlign: \"start\",\n scrollSnapStop: \"always\" satisfies React.CSSProperties[\"scrollSnapStop\"],\n } satisfies React.CSSProperties,\n };\n },\n [index, orientation],\n );\n\n const prev = useCallback(() => navigateTo(latest.current.index - 1, \"user:keyboard\"), [navigateTo]);\n const next = useCallback(() => navigateTo(latest.current.index + 1, \"user:keyboard\"), [navigateTo]);\n\n const api: SwipeDeckAPI<T> = useMemo(() => ({\n ...apiState,\n prev,\n next,\n scrollTo: (target, opts) => navigateTo(target, \"programmatic\", opts?.behavior),\n getViewportProps,\n getItemProps,\n virtualItems: virtualizer.virtualItems,\n totalSize: virtualizer.totalSize,\n items,\n orientation,\n viewport,\n }), [apiState, prev, next, navigateTo, getViewportProps, getItemProps, virtualizer.virtualItems, virtualizer.totalSize, items, orientation, viewport]);\n\n return api;\n}\n",
|
|
5
|
+
"import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type React from \"react\";\nimport { clamp } from \"../utils/clamp\";\nimport { prefersReducedMotion } from \"../utils/prefersReducedMotion\";\nimport { useGestures } from \"./useGestures\";\nimport { useWheel } from \"./useWheel\";\nimport { useKeyboard } from \"./useKeyboard\";\nimport { useVirtualizer } from \"./useVirtualizer\";\nimport type {\n Direction,\n IndexChangeSource,\n Orientation,\n ScrollBehavior,\n SwipeDeckAPI,\n SwipeDeckOptions,\n SwipeDeckState,\n} from \"../types\";\n\nconst DEFAULTS = {\n orientation: \"vertical\" as Orientation,\n direction: \"ltr\" as Direction,\n loop: false,\n defaultIndex: 0,\n gesture: {\n threshold: 10,\n flickVelocity: 0.1,\n lockAxis: true,\n ignoreWhileAnimating: true,\n },\n wheel: {\n discretePaging: true,\n threshold: 100,\n debounce: 120,\n cooldown: 800,\n },\n keyboard: {\n enabled: true,\n },\n visibility: {\n strategy: \"position\" as const,\n intersectionRatio: 0.6,\n debounce: 100,\n },\n virtual: {\n overscan: 5,\n },\n endReachedThreshold: 3,\n ariaLabel: \"Swipe feed\",\n keyboardNavigation: true,\n};\n\nexport function useSwipeDeck<T>(options: SwipeDeckOptions<T>): SwipeDeckAPI<T> {\n const items = options.items ?? [];\n const orientation = options.orientation ?? DEFAULTS.orientation;\n const direction = options.direction ?? DEFAULTS.direction;\n const loop = options.loop ?? DEFAULTS.loop;\n const defaultIndex = options.defaultIndex ?? DEFAULTS.defaultIndex;\n const preload = options.preload ?? 0;\n const preloadPrevious = options.preloadPrevious ?? 0;\n\n const gestureCfg = useMemo(() => ({ ...DEFAULTS.gesture, ...(options.gesture ?? {}) }), [options.gesture]);\n const wheelCfg = useMemo(() => ({ ...DEFAULTS.wheel, ...(options.wheel ?? {}) }), [options.wheel]);\n const keyboardCfg = useMemo(() => ({ ...DEFAULTS.keyboard, ...(options.keyboard ?? {}) }), [options.keyboard]);\n const virtualCfg = useMemo(() => {\n const base = { ...DEFAULTS.virtual, ...(options.virtual ?? {}) };\n // Ensure overscan is at least as large as preload + preloadPrevious to ensure all preloaded items are rendered\n const minOverscan = Math.max(preload, preloadPrevious);\n return {\n ...base,\n overscan: Math.max(base.overscan ?? 0, minOverscan),\n };\n }, [options.virtual, preload, preloadPrevious]);\n const endReachedThreshold = options.endReachedThreshold ?? DEFAULTS.endReachedThreshold;\n const ariaLabel = options.ariaLabel ?? DEFAULTS.ariaLabel;\n const keyboardNavigation = options.keyboardNavigation ?? true;\n\n const isControlled = typeof options.index === \"number\";\n const [internalIndex, setInternalIndex] = useState(() => clamp(defaultIndex, 0, Math.max(items.length - 1, 0)));\n const index = isControlled ? clamp(options.index ?? 0, 0, Math.max(items.length - 1, 0)) : internalIndex;\n\n const [isAnimating, setIsAnimating] = useState(false);\n\n // Use state for viewport to ensure hooks like useVirtualizer/useWheel know when it's ready\n const [viewport, setViewport] = useState<HTMLElement | null>(null);\n\n const sourceRef = useRef<IndexChangeSource>(\"snap\");\n const dragStartScrollRef = useRef<number>(0);\n const isNavigatingRef = useRef(false); // Track programmatic navigation to prevent scroll handler interference\n const snapRestoreTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null); // Track snap restore timeout\n const navigationStartRef = useRef<number>(0); // Track when navigation started for safety timeout\n const lastNavigationIndexRef = useRef<number>(-1); // Prevent duplicate navigations to same index\n const lastNavigationTimeRef = useRef<number>(0); // Cooldown between navigations\n\n useEffect(() => {\n // Clamp index when items change\n const clamped = clamp(index, 0, Math.max(items.length - 1, 0));\n if (!isControlled) setInternalIndex(clamped);\n }, [index, isControlled, items.length]);\n\n const virtualizer = useVirtualizer({\n items,\n virtual: virtualCfg,\n getScrollElement: useCallback(() => viewport, [viewport]),\n orientation,\n });\n\n // Stabilize callbacks using a ref for latest state\n const latest = useRef({\n index,\n items,\n isControlled,\n options,\n virtualizer,\n loop,\n orientation,\n setInternalIndex,\n setIsAnimating,\n viewport, // Add viewport to latest ref\n });\n\n // Update ref on every render\n latest.current = {\n index,\n items,\n isControlled,\n options,\n virtualizer,\n loop,\n orientation,\n setInternalIndex,\n setIsAnimating,\n viewport,\n };\n\n const applyIndexChange = useCallback(\n (nextIndex: number) => {\n const { index, isControlled, options, setInternalIndex, setIsAnimating } = latest.current;\n if (nextIndex === index) return;\n if (!isControlled) setInternalIndex(nextIndex);\n options.onIndexChange?.(nextIndex, sourceRef.current ?? \"snap\");\n setIsAnimating(false);\n sourceRef.current = \"snap\";\n },\n []\n );\n\n\n const navigateTo = useCallback(\n (targetIndex: number, source: IndexChangeSource, behavior?: ScrollBehavior) => {\n const { items, loop, index, isControlled, options, orientation, virtualizer, setInternalIndex, viewport } = latest.current;\n\n if (items.length === 0) return;\n const maxIndex = items.length - 1;\n let next = targetIndex;\n if (loop) {\n next = (next + items.length) % items.length;\n } else {\n next = clamp(next, 0, maxIndex);\n }\n\n // Don't navigate to same index unless it's a snap/correction\n if (next === index && source !== \"snap\") return;\n\n // Prevent rapid duplicate navigations (within 300ms to same index)\n const now = Date.now();\n if (next === lastNavigationIndexRef.current && now - lastNavigationTimeRef.current < 300) {\n return;\n }\n lastNavigationIndexRef.current = next;\n lastNavigationTimeRef.current = now;\n\n sourceRef.current = source;\n\n // Mark as navigating to prevent handleScroll from interfering\n isNavigatingRef.current = true;\n\n // Update index immediately\n if (!isControlled) setInternalIndex(next);\n options.onIndexChange?.(next, source);\n\n if (!viewport) return;\n\n // Clear any pending snap restore timeout\n if (snapRestoreTimeoutRef.current) {\n clearTimeout(snapRestoreTimeoutRef.current);\n snapRestoreTimeoutRef.current = null;\n }\n\n // CRITICAL: Temporarily disable scroll-snap during programmatic navigation\n // This prevents CSS from fighting with our scroll position\n viewport.style.scrollSnapType = 'none';\n viewport.style.scrollBehavior = 'auto';\n\n const targetBehavior = behavior ?? (prefersReducedMotion() ? \"instant\" : \"smooth\");\n\n // Manual scroll calculation\n const targetScroll = next * virtualizer.containerSize;\n\n // Track navigation start time for safety timeout\n navigationStartRef.current = Date.now();\n\n if (orientation === 'vertical') {\n viewport.scrollTo({ top: targetScroll, behavior: targetBehavior });\n } else {\n viewport.scrollTo({ left: targetScroll, behavior: targetBehavior });\n }\n\n // Handler to restore scroll-snap after navigation completes\n const handleScrollEnd = () => {\n isNavigatingRef.current = false;\n if (snapRestoreTimeoutRef.current) {\n clearTimeout(snapRestoreTimeoutRef.current);\n snapRestoreTimeoutRef.current = null;\n }\n if (viewport) {\n viewport.style.scrollSnapType = orientation === 'vertical' ? 'y mandatory' : 'x mandatory';\n }\n };\n\n // Use scrollend event if available (modern browsers), with fallback timeout\n if ('onscrollend' in window) {\n const scrollEndHandler = () => {\n handleScrollEnd();\n viewport.removeEventListener('scrollend', scrollEndHandler);\n };\n viewport.addEventListener('scrollend', scrollEndHandler, { once: true });\n // Safety fallback in case scrollend never fires\n snapRestoreTimeoutRef.current = setTimeout(() => {\n viewport.removeEventListener('scrollend', scrollEndHandler);\n handleScrollEnd();\n }, 800);\n } else {\n // Fallback for browsers without scrollend support\n const restoreDelay = targetBehavior === 'smooth' ? 500 : 50;\n snapRestoreTimeoutRef.current = setTimeout(handleScrollEnd, restoreDelay);\n }\n },\n []\n );\n\n const onDragStart = useCallback(() => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n // Optimization: Force auto behavior immediately on drag start\n viewport.style.scrollBehavior = 'auto';\n dragStartScrollRef.current = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n }\n }, []);\n\n const onDrag = useCallback((delta: number) => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n const newScroll = dragStartScrollRef.current - delta;\n if (orientation === \"vertical\") {\n viewport.scrollTop = newScroll;\n } else {\n viewport.scrollLeft = newScroll;\n }\n }\n }, []);\n\n // Calculate target index from current scroll position (for snap correction)\n const getSnapTargetIndex = useCallback(() => {\n const { viewport, orientation, items, virtualizer } = latest.current;\n if (!viewport || items.length === 0) return latest.current.index;\n\n const scrollOffset = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n const itemSize = virtualizer.containerSize || viewport.clientHeight;\n\n if (itemSize <= 0) return latest.current.index;\n\n const targetIndex = Math.round(scrollOffset / itemSize);\n return clamp(targetIndex, 0, items.length - 1);\n }, []);\n\n const wheel = useWheel({\n orientation,\n direction,\n discretePaging: wheelCfg.discretePaging ?? true,\n threshold: wheelCfg.threshold ?? 80,\n debounce: wheelCfg.debounce ?? 120,\n cooldown: wheelCfg.cooldown ?? 400,\n onRequestIndexChange: delta => navigateTo(latest.current.index + delta, \"user:wheel\"),\n viewport,\n onDragStart,\n onDrag,\n onDragEnd: () => {\n // Calculate correct target from scroll position, not from state\n const targetIndex = getSnapTargetIndex();\n navigateTo(targetIndex, \"snap\");\n },\n });\n\n const gestures = useGestures({\n orientation,\n direction,\n threshold: gestureCfg.threshold ?? 50,\n flickVelocity: gestureCfg.flickVelocity ?? 0.5,\n lockAxis: gestureCfg.lockAxis ?? true,\n ignoreWhileAnimating: gestureCfg.ignoreWhileAnimating ?? true,\n loop,\n getIndex: () => latest.current.index,\n maxIndex: Math.max(items.length - 1, 0),\n onRequestIndexChange: next => navigateTo(next, \"user:gesture\"),\n setAnimating: setIsAnimating,\n isAnimating,\n onDragStart,\n onDrag,\n });\n\n const keyboard = useKeyboard({\n orientation,\n direction,\n config: keyboardNavigation ? keyboardCfg : { enabled: false },\n onPrev: () => navigateTo(latest.current.index - 1, \"user:keyboard\"),\n onNext: () => navigateTo(latest.current.index + 1, \"user:keyboard\"),\n onFirst: () => navigateTo(0, \"user:keyboard\"),\n onLast: () => navigateTo(items.length - 1, \"user:keyboard\"),\n });\n\n // Calculate visibility based on scroll\n const rafId = useRef<number | null>(null);\n const scrollEndTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleScroll = useCallback(() => {\n // Safety: Force unlock if navigation has been stuck for too long (1.5 seconds)\n if (isNavigatingRef.current && Date.now() - navigationStartRef.current > 1500) {\n isNavigatingRef.current = false;\n console.warn('[SwipeDeck] Navigation lock timeout - forcing unlock');\n }\n\n // Skip scroll-based index calculation during programmatic navigation\n if (isNavigatingRef.current) return;\n\n // Safety Snap: If scrolling stops and we are misaligned, snap to current index\n if (scrollEndTimeoutRef.current) clearTimeout(scrollEndTimeoutRef.current);\n scrollEndTimeoutRef.current = setTimeout(() => {\n if (isNavigatingRef.current) return;\n const { viewport, orientation, index } = latest.current;\n if (!viewport) return;\n\n const scrollOffset = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n const computedSize = orientation === \"vertical\" ? viewport.clientHeight : viewport.clientWidth;\n const idealOffset = index * computedSize;\n\n // Use device pixel ratio for tolerance to handle high-DPI displays\n const dpr = typeof window !== 'undefined' ? window.devicePixelRatio : 1;\n const tolerance = Math.max(5, Math.ceil(5 * dpr));\n if (Math.abs(scrollOffset - idealOffset) > tolerance) {\n // We are stuck between frames. Snap to the current detected index.\n viewport.scrollTo({\n top: orientation === \"vertical\" ? idealOffset : 0,\n left: orientation === \"horizontal\" ? idealOffset : 0,\n behavior: 'smooth'\n });\n }\n }, 150); // 150ms debounce for \"scroll end\"\n\n if (rafId.current !== null) return;\n\n rafId.current = requestAnimationFrame(() => {\n rafId.current = null;\n\n // Double-check we're not navigating\n if (isNavigatingRef.current) return;\n\n const { viewport, orientation, items } = latest.current;\n if (!viewport) return;\n\n const scrollOffset = orientation === \"vertical\" ? viewport.scrollTop : viewport.scrollLeft;\n const viewportSize = orientation === \"vertical\" ? viewport.clientHeight : viewport.clientWidth;\n\n // Simple geometric calculation - works with CSS viewport units\n // Each item is 100dvh tall, so index = scrollOffset / viewportSize\n if (viewportSize > 0 && items.length > 0) {\n const estimatedIndex = Math.round(scrollOffset / viewportSize);\n const newIndex = clamp(estimatedIndex, 0, items.length - 1);\n applyIndexChange(newIndex);\n }\n });\n }, [applyIndexChange]); // applyIndexChange is stable now\n\n // onEndReached\n useEffect(() => {\n if (items.length === 0) return;\n const maxIndex = items.length - 1;\n const distanceFromEnd = maxIndex - index;\n if (distanceFromEnd <= endReachedThreshold) {\n options.onEndReached?.({ distanceFromEnd, direction: \"forward\" });\n }\n if (index <= endReachedThreshold) {\n options.onEndReached?.({ distanceFromEnd: index, direction: \"backward\" });\n }\n }, [endReachedThreshold, index, items.length, options]);\n\n const scrollBehavior = useMemo(\n () => (prefersReducedMotion() ? \"instant\" : \"smooth\"),\n [],\n );\n\n const scrollTo = useCallback(\n (target: number, opts?: { behavior?: ScrollBehavior }) => {\n navigateTo(target, \"programmatic\", opts?.behavior ?? scrollBehavior);\n },\n [navigateTo, scrollBehavior],\n );\n\n const apiState: SwipeDeckState = useMemo(\n () => ({\n index,\n isAnimating,\n canPrev: loop || index > 0,\n canNext: loop || index < items.length - 1,\n }),\n [index, isAnimating, items.length, loop],\n );\n\n // ═══════════════════════════════════════════════════════════════════════════\n // RESIZE HANDLING: Scroll Position Correction\n // ═══════════════════════════════════════════════════════════════════════════\n // CSS viewport units handle item sizing automatically.\n // But scroll position (in pixels) becomes invalid on resize.\n // We use the current index state to correct scroll position after resize settles.\n const resizeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (!viewport) return;\n\n const handleResize = () => {\n // Clear any pending correction\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n\n // After resize settles, snap scroll to current index\n resizeTimeoutRef.current = setTimeout(() => {\n const { orientation, index: currentIndex } = latest.current;\n if (!viewport) return;\n\n const size = orientation === 'vertical' ? viewport.clientHeight : viewport.clientWidth;\n const targetScroll = currentIndex * size;\n\n // Only correct if significantly off (avoid fighting with scroll-snap)\n const currentScroll = orientation === 'vertical' ? viewport.scrollTop : viewport.scrollLeft;\n if (Math.abs(currentScroll - targetScroll) > size * 0.1) {\n if (orientation === 'vertical') {\n viewport.scrollTop = targetScroll;\n } else {\n viewport.scrollLeft = targetScroll;\n }\n }\n }, 50);\n };\n\n const resizeObserver = new ResizeObserver(handleResize);\n resizeObserver.observe(viewport);\n\n return () => {\n resizeObserver.disconnect();\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n };\n }, [viewport]);\n\n // Re-enable scroll-snap when user touches the screen\n const handleTouchStart = useCallback(() => {\n const { viewport, orientation } = latest.current;\n if (viewport) {\n viewport.style.scrollSnapType = orientation === 'vertical' ? 'y mandatory' : 'x mandatory';\n }\n }, []);\n\n const getViewportProps = useCallback(() => {\n const virtualStyles: React.CSSProperties = {\n position: \"relative\",\n overflow: \"auto\",\n // Native Scroll Snap - handles touch swipe automatically\n scrollSnapType: orientation === \"vertical\" ? \"y mandatory\" : \"x mandatory\",\n // Allow native touch scrolling - this works with scroll-snap for smooth swipe experience\n touchAction: orientation === \"vertical\" ? \"pan-y\" : \"pan-x\",\n willChange: \"scroll-position\",\n };\n\n return {\n ref: setViewport,\n role: \"feed\",\n \"aria-label\": ariaLabel,\n \"aria-busy\": isAnimating,\n tabIndex: 0,\n onScroll: handleScroll,\n // onWheel: wheel.onWheel, // REMOVED: Managed internally by useWheel\n onKeyDown: keyboard.onKeyDown,\n onTouchStart: handleTouchStart,\n ...gestures.handlers,\n style: virtualStyles,\n } satisfies React.HTMLAttributes<HTMLElement> & { ref: React.RefCallback<HTMLElement> };\n }, [ariaLabel, handleScroll, handleTouchStart, isAnimating, keyboard.onKeyDown, orientation, gestures.handlers]);\n\n const getItemProps = useCallback(\n (itemIndex: number) => {\n const isActive = index === itemIndex;\n\n // Use CSS viewport units for positioning - these automatically update on rotation!\n // This is much simpler and more reliable than trying to correct pixel offsets.\n const sizeUnit = orientation === 'vertical' ? '100dvh' : '100dvw';\n\n return {\n ref: undefined,\n \"data-index\": itemIndex,\n \"data-active\": isActive,\n style: {\n position: \"absolute\" as const,\n top: 0,\n left: 0,\n // Use CSS calc with viewport units - browser handles rotation automatically!\n transform: orientation === 'vertical'\n ? `translateY(calc(${itemIndex} * ${sizeUnit}))`\n : `translateX(calc(${itemIndex} * ${sizeUnit}))`,\n height: orientation === 'vertical' ? sizeUnit : '100%',\n width: orientation === 'horizontal' ? sizeUnit : '100%',\n willChange: \"transform\",\n // Native Snap Item Styles\n scrollSnapAlign: \"start\",\n scrollSnapStop: \"always\" satisfies React.CSSProperties[\"scrollSnapStop\"],\n } satisfies React.CSSProperties,\n };\n },\n [index, orientation],\n );\n\n const prev = useCallback(() => navigateTo(latest.current.index - 1, \"user:keyboard\"), [navigateTo]);\n const next = useCallback(() => navigateTo(latest.current.index + 1, \"user:keyboard\"), [navigateTo]);\n\n const api: SwipeDeckAPI<T> = useMemo(() => ({\n ...apiState,\n prev,\n next,\n scrollTo: (target, opts) => navigateTo(target, \"programmatic\", opts?.behavior),\n getViewportProps,\n getItemProps,\n virtualItems: virtualizer.virtualItems,\n totalSize: virtualizer.totalSize,\n items,\n orientation,\n viewport,\n }), [apiState, prev, next, navigateTo, getViewportProps, getItemProps, virtualizer.virtualItems, virtualizer.totalSize, items, orientation, viewport]);\n\n return api;\n}\n",
|
|
6
6
|
"export function clamp(value: number, min: number, max: number): number {\n if (Number.isNaN(value)) return min;\n return Math.min(Math.max(value, min), max);\n}\n\n",
|
|
7
7
|
"let cached: boolean | null = null;\n\nexport function prefersReducedMotion(): boolean {\n if (cached !== null) return cached;\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n cached = false;\n return cached;\n }\n cached = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n return cached;\n}\n\n",
|
|
8
8
|
"import { useCallback, useRef, useState, useMemo } from \"react\";\nimport { clamp } from \"../utils/clamp\";\nimport type { Direction, Orientation } from \"../types\";\n\ntype GestureState = {\n isDragging: boolean;\n start: number;\n last: number;\n delta: number;\n startTime: number;\n};\n\ntype UseGesturesParams = {\n orientation: Orientation;\n direction: Direction;\n threshold: number;\n flickVelocity: number;\n lockAxis: boolean;\n ignoreWhileAnimating: boolean;\n loop: boolean;\n getIndex: () => number;\n maxIndex: number;\n onRequestIndexChange: (nextIndex: number) => void;\n setAnimating: (value: boolean) => void;\n isAnimating: boolean;\n onDragStart?: (evt: React.PointerEvent) => void;\n onDrag?: (delta: number, evt: React.PointerEvent) => void;\n onDragEnd?: () => void;\n};\n\nfunction primaryCoord(evt: PointerEvent | React.PointerEvent, orientation: Orientation) {\n return orientation === \"vertical\" ? evt.clientY : evt.clientX;\n}\n\n/**\n * Pointer/touch gestures (drag + flick). Mirrors the spec:\n * IDLE -> DRAGGING -> SETTLING with threshold + velocity decision.\n */\nexport function useGestures(params: UseGesturesParams) {\n const {\n orientation,\n direction,\n threshold,\n flickVelocity,\n lockAxis,\n ignoreWhileAnimating,\n loop,\n getIndex,\n maxIndex,\n onRequestIndexChange,\n setAnimating,\n isAnimating,\n onDragStart,\n onDrag,\n onDragEnd,\n } = params;\n\n const [isDragging, setIsDragging] = useState(false);\n const state = useRef<GestureState>({\n isDragging: false,\n start: 0,\n last: 0,\n delta: 0,\n startTime: 0,\n });\n\n const startDrag = useCallback((evt: React.PointerEvent) => {\n evt.currentTarget.setPointerCapture?.(evt.pointerId);\n const coord = primaryCoord(evt, orientation);\n state.current = {\n isDragging: true,\n start: coord,\n last: coord,\n delta: 0,\n startTime: performance.now(),\n };\n setIsDragging(true);\n onDragStart?.(evt);\n }, [orientation, onDragStart]);\n\n const updateDrag = useCallback((evt: React.PointerEvent) => {\n if (!state.current.isDragging) return;\n\n const coord = primaryCoord(evt, orientation);\n const delta = coord - state.current.start;\n state.current.delta = delta;\n state.current.last = coord;\n onDrag?.(delta, evt);\n }, [orientation, onDrag]);\n\n const endDrag = useCallback(() => {\n if (!state.current.isDragging) return;\n\n const now = performance.now();\n const duration = Math.max(now - state.current.startTime, 1);\n const distance = Math.abs(state.current.delta);\n const velocity = distance / duration; // px/ms\n\n const isForward = (() => {\n const raw = state.current.delta;\n if (orientation === \"vertical\") return raw < 0;\n // horizontal respects text direction\n const normalized = direction === \"rtl\" ? raw * -1 : raw;\n return normalized < 0;\n })();\n\n const current = getIndex();\n const deltaSign = isForward ? 1 : -1;\n const meetsFlick = velocity > flickVelocity;\n const meetsDistance = distance > threshold;\n\n let next = current;\n if (meetsFlick || meetsDistance) {\n next = current + deltaSign;\n }\n\n if (loop) {\n next = (next + (maxIndex + 1)) % (maxIndex + 1);\n } else {\n next = clamp(next, 0, maxIndex);\n }\n\n setAnimating(true);\n onRequestIndexChange(next);\n\n state.current.isDragging = false;\n state.current.delta = 0;\n setIsDragging(false);\n onDragEnd?.();\n }, [direction, flickVelocity, getIndex, maxIndex, onRequestIndexChange, orientation, loop, setAnimating, threshold, onDragEnd]);\n\n const cancelDrag = useCallback(() => {\n state.current.isDragging = false;\n state.current.delta = 0;\n setIsDragging(false);\n }, []);\n\n const onPointerDown = useCallback((evt: React.PointerEvent) => {\n if (ignoreWhileAnimating && isAnimating) return;\n if (evt.button !== 0) return;\n startDrag(evt);\n }, [ignoreWhileAnimating, isAnimating, startDrag]);\n\n const onPointerMove = useCallback((evt: React.PointerEvent) => {\n if (!lockAxis && !state.current.isDragging) return;\n if (state.current.isDragging) {\n updateDrag(evt);\n }\n }, [lockAxis, updateDrag]);\n\n const onPointerUp = useCallback(() => {\n endDrag();\n }, [endDrag]);\n\n const onPointerCancel = useCallback(() => {\n cancelDrag();\n }, [cancelDrag]);\n\n return useMemo(() => ({\n isDragging,\n handlers: { onPointerDown, onPointerMove, onPointerUp, onPointerCancel },\n }), [isDragging, onPointerDown, onPointerMove, onPointerUp, onPointerCancel]);\n}\n\n",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"import { useEffect, useLayoutEffect, useState, useMemo, useCallback } from \"react\";\nimport { useVirtualizer as useTanStackVirtualizer } from \"@tanstack/react-virtual\";\nimport type { VirtualConfig, SwipeDeckVirtualItem, Orientation } from \"../types\";\n\n// Use useLayoutEffect on client, useEffect on server (SSR safety)\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\ntype UseVirtualizerParams<T> = {\n items: readonly T[];\n virtual: VirtualConfig | undefined;\n getScrollElement: () => HTMLElement | null;\n orientation?: Orientation;\n};\n\ntype VirtualizerResult = {\n virtualItems: SwipeDeckVirtualItem[];\n totalSize: number;\n getItemOffset: (index: number) => number;\n getItemSize: (index: number) => number;\n scrollToIndex: (index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void;\n containerSize: number;\n};\n\n/**\n * Simplified adapter using @tanstack/react-virtual\n * Auto-detects viewport size when estimatedSize is not provided.\n */\nexport function useVirtualizer<T>(params: UseVirtualizerParams<T>): VirtualizerResult {\n const { items, virtual, getScrollElement, orientation = \"vertical\" } = params;\n const count = items.length;\n\n // Auto-detect viewport size when estimatedSize is not provided\n // Use state with a \"generation\" counter to force re-render when element is measured\n const [sizeState, setSizeState] = useState<{ size: number; measured: boolean }>(() => {\n // Initial fallback: use window size if available, else 800\n const fallback = typeof window !== \"undefined\"\n ? (orientation === \"vertical\" ? window.innerHeight : window.innerWidth)\n : 800;\n return { size: fallback, measured: false };\n });\n\n // Use useLayoutEffect to measure BEFORE paint - this fixes the black screen on initial load\n useIsomorphicLayoutEffect(() => {\n const scrollElement = getScrollElement();\n if (!scrollElement) return;\n\n const updateSize = () => {\n const size = orientation === \"vertical\"\n ? scrollElement.clientHeight\n : scrollElement.clientWidth;\n\n if (size > 0) {\n setSizeState(prev => {\n // Only update if size changed or first measurement\n if (prev.size !== size || !prev.measured) {\n return { size, measured: true };\n }\n return prev;\n });\n }\n };\n\n // Measure immediately (synchronously before paint)\n updateSize();\n\n // Watch for resizes\n const resizeObserver = new ResizeObserver(updateSize);\n resizeObserver.observe(scrollElement);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [getScrollElement, orientation]);\n\n const measuredSize = sizeState.size;\n\n // Always prioritize measured size for consistency - explicit estimatedSize is only used\n // if it's a function (for dynamic item sizes) or if we haven't measured yet\n const getEstimatedSize = useCallback((i: number): number => {\n const explicitSize = virtual?.estimatedSize;\n\n // If explicit size is a function, use it (supports dynamic item sizing)\n if (typeof explicitSize === 'function') {\n return explicitSize(items[i], i);\n }\n\n // Use measured size if available and valid, otherwise fall back to explicit or default\n if (measuredSize > 0) {\n return measuredSize;\n }\n\n // Fall back to explicit size or default\n return typeof explicitSize === 'number' ? explicitSize : 800;\n }, [virtual?.estimatedSize, items, measuredSize]);\n\n // Compute initialRect from window size for first render (before scroll element is available)\n const initialRect = useMemo(() => {\n if (typeof window === \"undefined\") {\n return { width: 800, height: 800 };\n }\n return {\n width: window.innerWidth,\n height: window.innerHeight,\n };\n }, []);\n\n // Memoize getItemKey wrapper to prevent infinite re-renders\n const getItemKey = useMemo(() => {\n if (!virtual?.getItemKey) return undefined;\n return (index: number) => virtual.getItemKey?.(items[index], index) ?? index;\n }, [virtual?.getItemKey, items]);\n\n const rowVirtualizer = useTanStackVirtualizer({\n count,\n getScrollElement,\n estimateSize: getEstimatedSize,\n overscan: virtual?.overscan ?? 5,\n horizontal: orientation === \"horizontal\",\n getItemKey,\n // CRITICAL: Provide initialRect so virtualizer can calculate items on first render\n // even when getScrollElement() returns null\n initialRect,\n });\n\n // NOTE: Do NOT wrap this in useMemo! The rowVirtualizer object is stable,\n // but getVirtualItems() returns different results on each scroll event.\n // Wrapping in useMemo causes stale virtualItems that don't update on scroll.\n return {\n virtualItems: rowVirtualizer.getVirtualItems().map(item => ({\n index: item.index,\n key: item.key as string | number,\n offset: item.start,\n size: item.size,\n measureElement: rowVirtualizer.measureElement,\n })),\n totalSize: rowVirtualizer.getTotalSize(),\n getItemOffset: (index: number) => {\n const found = rowVirtualizer.getVirtualItems().find(v => v.index === index);\n return found ? found.start : 0;\n },\n getItemSize: (index: number) => {\n const found = rowVirtualizer.getVirtualItems().find(v => v.index === index);\n return found ? found.size : 0;\n },\n scrollToIndex: (index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => {\n rowVirtualizer.scrollToIndex(index, {\n align: options?.align,\n behavior: options?.behavior,\n });\n },\n containerSize: measuredSize,\n };\n}\n",
|
|
12
12
|
"import { useState, useEffect } from \"react\";\n\nexport function useWindowSize() {\n const [size, setSize] = useState<{ width: number; height: number }>({\n width: typeof window !== \"undefined\" ? window.innerWidth : 0,\n height: typeof window !== \"undefined\" ? window.innerHeight : 0,\n });\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n let timeoutId: ReturnType<typeof setTimeout>;\n\n const handleResize = () => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n setSize({ width: window.innerWidth, height: window.innerHeight });\n }, 100);\n };\n\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n clearTimeout(timeoutId);\n };\n }, []);\n\n return size;\n}\n",
|
|
13
13
|
"import { createContext, useContext } from 'react';\nimport type { SwipeDeckRenderContext } from '../types';\n\n// biome-ignore lint/suspicious/noExplicitAny: Context defaults to any\nexport const SwipeItemContext = createContext<SwipeDeckRenderContext<any> | undefined>(undefined);\n\n// biome-ignore lint/suspicious/noExplicitAny: Generic defaults to any\nexport function useSwipeItem<T = any>(): SwipeDeckRenderContext<T> {\n const context = useContext(SwipeItemContext);\n if (!context) {\n throw new Error(\"useSwipeItem must be used within a SwipeDeck item\");\n }\n return context;\n}\n",
|
|
14
|
-
"\nimport type React from \"react\";\nimport { useImperativeHandle, useMemo } from \"react\";\nimport { useSwipeDeck } from \"../hooks/useSwipeDeck\";\nimport { SwipeItemContext } from \"../hooks/useSwipeItem\";\nimport type { SwipeDeckHandle, SwipeDeckProps } from \"../types\";\n\nexport function SwipeDeck<T>(\n props: SwipeDeckProps<T> & { ref?: React.Ref<SwipeDeckHandle> },\n) {\n const {\n as: As = \"div\",\n children,\n className,\n style,\n ref,\n ...options\n } = props;\n\n const deck = useSwipeDeck(options);\n\n useImperativeHandle(\n ref,\n () => ({\n prev: deck.prev,\n next: deck.next,\n scrollTo: deck.scrollTo,\n getState: () => ({\n index: deck.index,\n isAnimating: deck.isAnimating,\n canPrev: deck.canPrev,\n canNext: deck.canNext,\n }),\n viewport: deck.viewport,\n }),\n [deck],\n );\n\n const { style: virtualStyle, ...restViewportProps } = deck.getViewportProps();\n\n /* Fullscreen styles if enabled */\n const fullscreenStyle: React.CSSProperties = props.fullscreen\n ? {\n height: \"100dvh\",\n width: \"100%\",\n position: \"absolute\",\n top: 0,\n left: 0,\n }\n : {};\n\n const viewportStyle = useMemo(\n () => ({ ...virtualStyle, ...fullscreenStyle, ...style }),\n [virtualStyle, fullscreenStyle, style],\n );\n\n const contentStyle = useMemo<React.CSSProperties>(\n () => ({\n // Use CSS viewport units for total size - automatically updates on rotation!\n height: deck.orientation === \"vertical\"\n ? `calc(${deck.items.length} * 100dvh)`\n : \"100%\",\n width: deck.orientation === \"horizontal\"\n ? `calc(${deck.items.length} * 100dvw)`\n : \"100%\",\n position: \"relative\",\n }),\n [deck.orientation, deck.items.length],\n );\n\n // Cast As to ElementType to avoid TS issues with polymorphic string/component\n const Comp = As as React.ElementType;\n\n return (\n <Comp\n {...restViewportProps}\n className={className}\n style={viewportStyle}\n >\n <div style={contentStyle}>\n {deck.
|
|
14
|
+
"\nimport type React from \"react\";\nimport { useImperativeHandle, useMemo } from \"react\";\nimport { useSwipeDeck } from \"../hooks/useSwipeDeck\";\nimport { SwipeItemContext } from \"../hooks/useSwipeItem\";\nimport type { SwipeDeckHandle, SwipeDeckProps } from \"../types\";\n\nexport function SwipeDeck<T>(\n props: SwipeDeckProps<T> & { ref?: React.Ref<SwipeDeckHandle> },\n) {\n const {\n as: As = \"div\",\n children,\n className,\n style,\n ref,\n ...options\n } = props;\n\n const deck = useSwipeDeck(options);\n\n useImperativeHandle(\n ref,\n () => ({\n prev: deck.prev,\n next: deck.next,\n scrollTo: deck.scrollTo,\n getState: () => ({\n index: deck.index,\n isAnimating: deck.isAnimating,\n canPrev: deck.canPrev,\n canNext: deck.canNext,\n }),\n viewport: deck.viewport,\n }),\n [deck],\n );\n\n const { style: virtualStyle, ...restViewportProps } = deck.getViewportProps();\n\n /* Fullscreen styles if enabled */\n const fullscreenStyle: React.CSSProperties = props.fullscreen\n ? {\n height: \"100dvh\",\n width: \"100%\",\n position: \"absolute\",\n top: 0,\n left: 0,\n }\n : {};\n\n const viewportStyle = useMemo(\n () => ({ ...virtualStyle, ...fullscreenStyle, ...style }),\n [virtualStyle, fullscreenStyle, style],\n );\n\n const contentStyle = useMemo<React.CSSProperties>(\n () => ({\n // Use CSS viewport units for total size - automatically updates on rotation!\n height: deck.orientation === \"vertical\"\n ? `calc(${deck.items.length} * 100dvh)`\n : \"100%\",\n width: deck.orientation === \"horizontal\"\n ? `calc(${deck.items.length} * 100dvw)`\n : \"100%\",\n position: \"relative\",\n }),\n [deck.orientation, deck.items.length],\n );\n\n // Cast As to ElementType to avoid TS issues with polymorphic string/component\n const Comp = As as React.ElementType;\n\n return (\n <Comp\n {...restViewportProps}\n className={className}\n style={viewportStyle}\n >\n <div style={contentStyle}>\n {/* Use virtualItems for windowed rendering - only renders visible + overscan items */}\n {deck.virtualItems.map((virtualItem) => {\n const itemIndex = virtualItem.index;\n const item = deck.items[itemIndex];\n if (!item) return null;\n\n const itemProps = deck.getItemProps(itemIndex);\n const preload = options.preload ?? 0;\n const preloadPrevious = options.preloadPrevious ?? 0;\n\n let shouldPreload = false;\n // Check if we should preload (either next items or previous items)\n if (preload > 0 || preloadPrevious > 0) {\n const currentIndex = deck.index;\n\n if (!options.loop) {\n // Non-loop: simple index comparison\n const isNext = itemIndex > currentIndex && itemIndex <= currentIndex + preload;\n const isPrev = itemIndex < currentIndex && itemIndex >= currentIndex - preloadPrevious;\n shouldPreload = isNext || isPrev;\n } else {\n // Loop: calculate distance in both directions\n const len = deck.items.length;\n // Forward distance (0 to len-1)\n const forwardDist = (itemIndex - currentIndex + len) % len;\n // Backward distance (0 to len-1)\n const backwardDist = (currentIndex - itemIndex + len) % len;\n\n const isNext = forwardDist > 0 && forwardDist <= preload;\n const isPrev = backwardDist > 0 && backwardDist <= preloadPrevious;\n shouldPreload = isNext || isPrev;\n }\n }\n\n // Don't pass style to children - the article wrapper already handles positioning\n // Children should use inset: 0 to fill the parent\n const { style: _positioningStyle, ...propsWithoutStyle } = itemProps;\n\n const contextValue = {\n item,\n index: itemIndex,\n isActive: deck.index === itemIndex,\n shouldPreload,\n props: propsWithoutStyle,\n };\n\n // Use virtualItem.key for stable keys\n const itemKey = virtualItem.key ?? (options.virtual?.getItemKey?.(item, itemIndex) ?? itemIndex);\n\n return (\n <article\n key={itemKey}\n {...itemProps}\n aria-label={`Item ${itemIndex + 1} of ${deck.items.length}`}\n >\n <SwipeItemContext.Provider value={contextValue}>\n {children(contextValue)}\n </SwipeItemContext.Provider>\n </article>\n );\n })}\n </div>\n </Comp>\n );\n}\n\n"
|
|
15
15
|
],
|
|
16
|
-
"mappings": ";AAAA,wBAAS,2BAAa,uBAAW,oBAAS,qBAAQ;;;ACA3C,SAAS,KAAK,CAAC,OAAe,KAAa,KAAqB;AAAA,EACrE,IAAI,OAAO,MAAM,KAAK;AAAA,IAAG,OAAO;AAAA,EAChC,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAAA;;;ACF3C,IAAI,SAAyB;AAEtB,SAAS,oBAAoB,GAAY;AAAA,EAC9C,IAAI,WAAW;AAAA,IAAM,OAAO;AAAA,EAC5B,IAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAAA,IAC5E,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,SAAS,OAA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AAa,EAAe,EACvE,EAAgB,GAAU,EACrB,KAEL,IAAM,EAAM,EAAK,MAAM,OAEjB,GAAe,EAAY,EAAe,GAAO,EAEjD,GAAgB,EAAe,EAAY,GAAO,EAElD,EAAS,EAAc,GAAK,GAAe,EAC3C,EAAS,EAAe,GAAK,GAAgB,EACnD,EAAgB,GAAU,GAM9B,IAAQ,MAAO,KAAsB,GAAsB,EAErD,EAAe,CACnB,OACA,MAAO,EACP,SAAU,EAAK,QAAU,EACzB,gBACA,MAAO,CACT,EAGM,EAAU,EAAY,MAAQ,EAAQ,SAAS,aAAa,EAAM,CAAS,GAAK,GAEtF,OACE,GAQE,UARF,IAEM,EACJ,aAAY,QAAQ,EAAY,QAAQ,EAAK,MAAM,SAHrD,SAKE,GAEE,GAAiB,SAFnB,CAA2B,MAAO,EAAlC,SACG,EAAS,CAAY,EACtB,GANG,CAOL,EAEL,EACD,EACF",
|
|
17
|
+
"debugId": "9F0C3AACC03F3E5E64756E2164756E21",
|
|
18
18
|
"names": []
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swipefeed",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "bun build src/index.ts --target=browser --outdir=dist --sourcemap --external react --external react-dom --external @tanstack/react-virtual && tsc --declaration --emitDeclarationOnly --outDir dist --noEmit false",
|
|
33
|
+
"build": "bun build src/index.ts --target=browser --outdir=dist --sourcemap --production --external react --external react-dom --external @tanstack/react-virtual && tsc --declaration --emitDeclarationOnly --outDir dist --noEmit false",
|
|
34
34
|
"prepublishOnly": "bun run build",
|
|
35
35
|
"docs:api": "typedoc",
|
|
36
36
|
"docs:site": "typedoc --options typedoc.site.json",
|