Socket
Socket
Sign inDemoInstall

@alzera/react-infinite-scroll

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

publish.command

2

dist/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),i=require("react");var m=(e=>(e[e.stale=0]="stale",e[e.loading=1]="loading",e))(m||{});const I=({onRefresh:e,startMin:l=100,maxLength:d=100,threshold:f=100,useWindow:o=!0})=>{const s=i.useRef(null),a=i.useRef(0),[h,E]=i.useState(0),w=i.useRef(0);w.current=h;const[x,v]=i.useState(m.stale);i.useEffect(()=>{x==m.loading&&(async()=>(await e(),v(m.stale)))()},[x]);const p=()=>{var r;return o?typeof window>"u"?null:window:(r=s.current)==null?void 0:r.parentElement};return i.useEffect(()=>{const r=p();if(!r)return;const R=({targetTouches:c})=>{var Y,j;const u=c[0];if(!u)return;(o?window.scrollY:((j=(Y=s.current)==null?void 0:Y.parentElement)==null?void 0:j.scrollTop)||0)<l&&(a.current=u.screenY)},g=c=>{const u=c.targetTouches[0];if(!u||a.current==0)return;c.preventDefault();const b=a.current<u.screenY?Math.min(Math.abs(u.screenY-a.current),d):0;E(b)},y=()=>{const c=w.current>=f;a.current=0,E(0),c&&v(m.loading)};return r.addEventListener("touchstart",R),r.addEventListener("touchmove",g),r.addEventListener("touchend",y),()=>{r.removeEventListener("touchstart",R),r.removeEventListener("touchmove",g),r.removeEventListener("touchend",y)}}),{state:x,pullPosition:h,element:s}};var n=(e=>(e[e.stale=0]="stale",e[e.loading=1]="loading",e[e.noMore=2]="noMore",e[e.empty=3]="empty",e))(n||{});const k=e=>{const l=i.useRef(null),[d,f]=i.useState({state:n.stale,page:0});return i.useEffect(()=>{if(!l.current)return;new IntersectionObserver(async s=>{s[0].isIntersecting&&f(a=>{if(a.state!=n.stale)return a;const h=structuredClone(a);return h.state=n.loading,h})}).observe(l.current)},[l]),i.useEffect(()=>{d.state==n.loading&&(async()=>{const o=await e(structuredClone(d));o.state==n.loading&&(o.state=n.stale),f(o)})()},[d]),{param:d,setParam:f,anchor:l}};function M(){return t.jsx("span",{style:{background:"#000",borderRadius:"50%",width:"40px",height:"40px",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsx("span",{style:{width:"30px",height:"30px",border:"5px solid #fff",borderBottomColor:"transparent",borderRadius:"50%",display:"inline-block",animation:"rotation 1s linear infinite"},children:t.jsx("style",{children:"@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"})})})}function q({children:e,loadingView:l,noMoreView:d,emptyView:f,isReverse:o,onController:s,onLoadMore:a,pullStartMin:h,pullMaxLength:E,pullThreshold:w,pullUseWindow:x,pullView:v,onPull:p,style:r,className:R}){const{param:g,setParam:y,anchor:c}=k(a),{state:u,pullPosition:b,element:Y}=I({startMin:h,maxLength:E,threshold:w,useWindow:x,onRefresh:async()=>{await(p==null?void 0:p())&&y({state:n.stale,page:0})}});i.useEffect(()=>(s==null||s({resetPage:(P=!1)=>{y({state:P?n.loading:n.stale,page:0})}}),()=>{s==null||s(null)}));const j=g.state==n.loading?l||t.jsx("span",{children:"Loading..."}):g.state==n.noMore?d||t.jsx("span",{children:"No more item!"}):g.state==n.empty?f||t.jsx("span",{children:"List is empty!"}):null,L=p&&(v?v(u,b):t.jsx("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",height:"40px",padding:"8px",boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center",transition:"transform 250ms ease-in",transform:`translateY(${u?40:b}px)`},children:t.jsx(M,{})}));return t.jsx("div",{ref:Y,className:R,style:{...r,position:"relative",overflow:"hidden"},children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:c}),j,e,L]}):t.jsxs(t.Fragment,{children:[L,e,j,t.jsx("div",{ref:c})]})})}exports.LoadMoreState=n;exports.PullToRefreshState=m;exports.default=q;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),i=require("react");var m=(e=>(e[e.stale=0]="stale",e[e.loading=1]="loading",e))(m||{});const I=({onRefresh:e,startMin:l=100,maxLength:d=100,threshold:f=100,useWindow:o=!0})=>{const s=i.useRef(null),a=i.useRef(0),[h,E]=i.useState(0),w=i.useRef(0);w.current=h;const[x,v]=i.useState(m.stale);i.useEffect(()=>{x==m.loading&&(async()=>(await e(),v(m.stale)))()},[x]);const p=()=>{var r;return o?typeof window>"u"?null:window:(r=s.current)==null?void 0:r.parentElement};return i.useEffect(()=>{const r=p();if(!r)return;const R=({targetTouches:c})=>{var Y,j;const u=c[0];if(!u)return;(o?window.scrollY:((j=(Y=s.current)==null?void 0:Y.parentElement)==null?void 0:j.scrollTop)||0)<l&&(a.current=u.screenY)},g=c=>{const u=c.targetTouches[0];if(!u||a.current==0)return;c.preventDefault();const b=a.current<u.screenY?Math.min(Math.abs(u.screenY-a.current),d):0;E(b)},y=()=>{const c=w.current>=f;a.current=0,E(0),c&&v(m.loading)};return r.addEventListener("touchstart",R),r.addEventListener("touchmove",g),r.addEventListener("touchend",y),()=>{r.removeEventListener("touchstart",R),r.removeEventListener("touchmove",g),r.removeEventListener("touchend",y)}}),{state:x,pullPosition:h,element:s}};var n=(e=>(e[e.stale=0]="stale",e[e.loading=1]="loading",e[e.noMore=2]="noMore",e[e.empty=3]="empty",e))(n||{});const k=e=>{const l=i.useRef(null),[d,f]=i.useState({state:n.stale,page:0});return i.useEffect(()=>{if(!l.current)return;new IntersectionObserver(async s=>{s[0].isIntersecting&&f(a=>{if(a.state!=n.stale)return a;const h=structuredClone(a);return h.state=n.loading,h})}).observe(l.current)},[l]),i.useEffect(()=>{d.state==n.loading&&(async()=>{const o=await e(structuredClone(d));o.state==n.loading&&(o.state=n.stale),f(o)})()},[d]),{param:d,setParam:f,anchor:l}};function M(){return t.jsx("span",{style:{background:"#000",borderRadius:"50%",width:"40px",height:"40px",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsx("span",{style:{width:"30px",height:"30px",border:"5px solid #fff",borderBottomColor:"transparent",borderRadius:"50%",display:"inline-block",animation:"rotation 1s linear infinite"},children:t.jsx("style",{children:"@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"})})})}function q({children:e,loadingView:l,noMoreView:d,emptyView:f,isReverse:o,onController:s,onLoadMore:a,pullStartMin:h,pullMaxLength:E,pullThreshold:w,pullUseWindow:x,pullView:v,onPull:p,style:r,className:R}){const{param:g,setParam:y,anchor:c}=k(a),{state:u,pullPosition:b,element:Y}=I({startMin:h,maxLength:E,threshold:w,useWindow:x,onRefresh:async()=>{await(p==null?void 0:p())&&y({state:n.stale,page:0})}});i.useEffect(()=>(s==null||s({resetPage:(P=!1)=>{y({state:P?n.loading:n.stale,page:0})}}),()=>{s==null||s(null)}),[]);const j=g.state==n.loading?l||t.jsx("span",{children:"Loading..."}):g.state==n.noMore?d||t.jsx("span",{children:"No more item!"}):g.state==n.empty?f||t.jsx("span",{children:"List is empty!"}):null,L=p&&(v?v(u,b):t.jsx("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",height:"40px",padding:"8px",boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center",transition:"transform 250ms ease-in",transform:`translateY(${u?40:b}px)`},children:t.jsx(M,{})}));return t.jsx("div",{ref:Y,className:R,style:{...r,position:"relative",overflow:"hidden"},children:o?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:c}),j,e,L]}):t.jsxs(t.Fragment,{children:[L,e,j,t.jsx("div",{ref:c})]})})}exports.LoadMoreState=n;exports.PullToRefreshState=m;exports.default=q;

@@ -128,3 +128,3 @@ import { jsx as i, jsxs as D, Fragment as z } from "react/jsx-runtime";

n == null || n(null);
}));
}), []);
const b = h.state == t.loading ? l || /* @__PURE__ */ i("span", { children: "Loading..." }) : h.state == t.noMore ? u || /* @__PURE__ */ i("span", { children: "No more item!" }) : h.state == t.empty ? d || /* @__PURE__ */ i("span", { children: "List is empty!" }) : null, R = p && (g ? g(c, y) : /* @__PURE__ */ i("div", { style: {

@@ -131,0 +131,0 @@ position: "absolute",

{
"name": "@alzera/react-infinite-scroll",
"version": "0.0.2",
"version": "0.0.3",
"description": "Infinite scroll component for React apps",

@@ -29,4 +29,3 @@ "license": "MIT",

"preview": "vite preview",
"analyze": "npx vite-bundle-visualizer",
"publish": "npm publish --access public"
"analyze": "npx vite-bundle-visualizer"
},

@@ -33,0 +32,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc