Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

v3-infinite-loading

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v3-infinite-loading - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

4

lib/components/InfiniteLoading.vue.d.ts

@@ -9,3 +9,3 @@ import type { PropType as __PropType } from 'vue';

target: {
type: __PropType<import('../types').Target>;
type: __PropType<import('../types').Target | undefined>;
required: false;

@@ -38,3 +38,3 @@ };

target: {
type: __PropType<import('../types').Target>;
type: __PropType<import('../types').Target | undefined>;
required: false;

@@ -41,0 +41,0 @@ };

import type { Ref } from "vue";
export type Target = HTMLElement | string | null | undefined;
export type Target = HTMLElement | string;
export type State = "" | "loading" | "loaded" | "complete" | "error";

@@ -4,0 +4,0 @@ export interface StateHandler {

@@ -1,13 +0,12 @@

import { nextTick as h, openBlock as E, createElementBlock as w, pushScopeId as B, popScopeId as H, createElementVNode as s, defineComponent as C, ref as m, toRefs as R, watch as b, onMounted as N, onUnmounted as O, withDirectives as V, renderSlot as u, createVNode as M, vShow as T, toDisplayString as v, createCommentVNode as g } from "vue";
function D(e, o) {
const n = e.getBoundingClientRect();
if (!o)
return n.top >= 0 && n.bottom <= window.innerHeight;
const t = o.getBoundingClientRect();
return n.top >= t.top && n.bottom <= t.bottom;
import { nextTick as h, openBlock as w, createElementBlock as E, pushScopeId as B, popScopeId as H, createElementVNode as c, defineComponent as C, ref as v, toRefs as O, watch as R, onMounted as N, onUnmounted as V, withDirectives as M, renderSlot as u, createVNode as T, vShow as D, toDisplayString as g, createCommentVNode as m } from "vue";
function P(e, o = null) {
if (!e)
return !1;
const n = e.getBoundingClientRect(), t = o ? o.getBoundingClientRect() : { top: 0, left: 0, bottom: window.innerHeight, right: window.innerWidth };
return n.bottom >= t.top && n.top <= t.bottom && n.right >= t.left && n.left <= t.right;
}
async function q(e) {
return await h(), e.value instanceof HTMLElement ? e.value : e.value ? document.querySelector(e.value) : null;
return e ? (await h(), e.value instanceof HTMLElement ? e.value : e.value ? document.querySelector(e.value) : null) : null;
}
function y(e) {
function U(e) {
let o = `0px 0px ${e.distance}px 0px`;

@@ -21,16 +20,22 @@ e.top && (o = `${e.distance}px 0px 0px 0px`);

);
return n.observe(e.infiniteLoading.value), n;
return e.infiniteLoading.value && n.observe(e.infiniteLoading.value), n;
}
async function y(e, o) {
if (await h(), !e.top)
return;
const n = e.parentEl || document.documentElement;
n.scrollTop = n.scrollHeight - o;
}
const x = (e, o) => {
const n = e.__vccOpts || e;
for (const [t, c] of o)
n[t] = c;
for (const [t, r] of o)
n[t] = r;
return n;
}, P = {}, U = (e) => (B("data-v-d3e37633"), e = e(), H(), e), j = { class: "container" }, z = /* @__PURE__ */ U(() => /* @__PURE__ */ s("div", { class: "spinner" }, null, -1)), A = [
z
}, W = {}, j = (e) => (B("data-v-d3e37633"), e = e(), H(), e), z = { class: "container" }, A = /* @__PURE__ */ j(() => /* @__PURE__ */ c("div", { class: "spinner" }, null, -1)), F = [
A
];
function F(e, o) {
return E(), w("div", j, A);
function G(e, o) {
return w(), E("div", z, F);
}
const G = /* @__PURE__ */ x(P, [["render", F], ["__scopeId", "data-v-d3e37633"]]), J = { class: "state-error" }, K = /* @__PURE__ */ C({
const J = /* @__PURE__ */ x(W, [["render", G], ["__scopeId", "data-v-d3e37633"]]), K = { class: "state-error" }, Q = /* @__PURE__ */ C({
__name: "InfiniteLoading",

@@ -48,53 +53,50 @@ props: {

const n = e;
let t = null, c = 0;
const d = m(null), r = m(""), { top: p, firstload: I, distance: S } = n, { identifier: k, target: L } = R(n), i = {
let t = null, r = 0;
const d = v(null), l = v(""), { top: I, firstload: S, distance: k } = n, { identifier: L, target: b } = O(n), i = {
infiniteLoading: d,
top: p,
firstload: I,
distance: S,
top: I,
firstload: S,
distance: k,
parentEl: null,
emit() {
c = (i.parentEl || document.documentElement).scrollHeight, f.loading(), o("infinite", f);
r = (i.parentEl || document.documentElement).scrollHeight, p.loading(), o("infinite", p);
}
}, f = {
}, p = {
loading() {
r.value = "loading";
l.value = "loading";
},
async loaded() {
r.value = "loaded";
const l = i.parentEl || document.documentElement;
await h(), p && (l.scrollTop = l.scrollHeight - c), D(d.value, i.parentEl) && i.emit();
l.value = "loaded", await y(i, r), P(d.value, i.parentEl) && i.emit();
},
complete() {
r.value = "complete", t == null || t.disconnect();
async complete() {
l.value = "complete", await y(i, r), t == null || t.disconnect();
},
error() {
r.value = "error";
l.value = "error";
}
};
return b(k, () => {
t == null || t.disconnect(), t = y(i);
}), N(async () => {
i.parentEl = await q(L), t = y(i);
}), O(() => {
t == null || t.disconnect();
}), (l, _) => (E(), w("div", {
function f() {
t == null || t.disconnect(), t = U(i);
}
return R(L, f), N(async () => {
i.parentEl = await q(b), f();
}), V(() => t == null ? void 0 : t.disconnect()), (s, _) => (w(), E("div", {
ref_key: "infiniteLoading",
ref: d,
style: { "min-height": "1px" }
class: "v3-infinite-loading"
}, [
V(s("div", null, [
u(l.$slots, "spinner", {}, () => [
M(G)
M(c("div", null, [
u(s.$slots, "spinner", {}, () => [
T(J)
], !0)
], 512), [
[T, r.value == "loading"]
[D, l.value == "loading"]
]),
r.value == "complete" ? u(l.$slots, "complete", { key: 0 }, () => {
l.value == "complete" ? u(s.$slots, "complete", { key: 0 }, () => {
var a;
return [
s("span", null, v(((a = l.slots) == null ? void 0 : a.complete) || "No more results!"), 1)
c("span", null, g(((a = s.slots) == null ? void 0 : a.complete) || "No more results!"), 1)
];
}, !0) : g("", !0),
r.value == "error" ? u(l.$slots, "error", {
}, !0) : m("", !0),
l.value == "error" ? u(s.$slots, "error", {
key: 1,

@@ -105,5 +107,5 @@ retry: i.emit

return [
s("span", J, [
s("span", null, v(((a = l.slots) == null ? void 0 : a.error) || "Oops something went wrong!"), 1),
s("button", {
c("span", K, [
c("span", null, g(((a = s.slots) == null ? void 0 : a.error) || "Oops something went wrong!"), 1),
c("button", {
class: "retry",

@@ -115,9 +117,9 @@ onClick: _[0] || (_[0] = //@ts-ignore

];
}, !0) : g("", !0)
}, !0) : m("", !0)
], 512));
}
});
const W = /* @__PURE__ */ x(K, [["__scopeId", "data-v-a7077831"]]);
const Y = /* @__PURE__ */ x(Q, [["__scopeId", "data-v-4bdee133"]]);
export {
W as default
Y as default
};

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

(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.V3InfiniteLoading={},s.Vue))})(this,function(s,e){"use strict";function y(t,i){const o=t.getBoundingClientRect();if(!i)return o.top>=0&&o.bottom<=window.innerHeight;const n=i.getBoundingClientRect();return o.top>=n.top&&o.bottom<=n.bottom}async function E(t){return await e.nextTick(),t.value instanceof HTMLElement?t.value:t.value?document.querySelector(t.value):null}function f(t){let i=`0px 0px ${t.distance}px 0px`;t.top&&(i=`${t.distance}px 0px 0px 0px`);const o=new IntersectionObserver(n=>{n[0].isIntersecting&&(t.firstload&&t.emit(),t.firstload=!0)},{root:t.parentEl,rootMargin:i});return o.observe(t.infiniteLoading.value),o}const H="",u=(t,i)=>{const o=t.__vccOpts||t;for(const[n,d]of i)o[n]=d;return o},h={},S=t=>(e.pushScopeId("data-v-d3e37633"),t=t(),e.popScopeId(),t),x={class:"container"},w=[S(()=>e.createElementVNode("div",{class:"spinner"},null,-1))];function V(t,i){return e.openBlock(),e.createElementBlock("div",x,w)}const k=u(h,[["render",V],["__scopeId","data-v-d3e37633"]]),I={class:"state-error"},N=e.defineComponent({__name:"InfiniteLoading",props:{top:{type:Boolean,default:!1},target:{},distance:{default:0},identifier:{},firstload:{type:Boolean,default:!0},slots:{}},emits:["infinite"],setup(t,{emit:i}){const o=t;let n=null,d=0;const p=e.ref(null),c=e.ref(""),{top:_,firstload:L,distance:T}=o,{identifier:$,target:b}=e.toRefs(o),l={infiniteLoading:p,top:_,firstload:L,distance:T,parentEl:null,emit(){d=(l.parentEl||document.documentElement).scrollHeight,m.loading(),i("infinite",m)}},m={loading(){c.value="loading"},async loaded(){c.value="loaded";const r=l.parentEl||document.documentElement;await e.nextTick(),_&&(r.scrollTop=r.scrollHeight-d),y(p.value,l.parentEl)&&l.emit()},complete(){c.value="complete",n==null||n.disconnect()},error(){c.value="error"}};return e.watch($,()=>{n==null||n.disconnect(),n=f(l)}),e.onMounted(async()=>{l.parentEl=await E(b),n=f(l)}),e.onUnmounted(()=>{n==null||n.disconnect()}),(r,g)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"infiniteLoading",ref:p,style:{"min-height":"1px"}},[e.withDirectives(e.createElementVNode("div",null,[e.renderSlot(r.$slots,"spinner",{},()=>[e.createVNode(k)],!0)],512),[[e.vShow,c.value=="loading"]]),c.value=="complete"?e.renderSlot(r.$slots,"complete",{key:0},()=>{var a;return[e.createElementVNode("span",null,e.toDisplayString(((a=r.slots)==null?void 0:a.complete)||"No more results!"),1)]},!0):e.createCommentVNode("",!0),c.value=="error"?e.renderSlot(r.$slots,"error",{key:1,retry:l.emit},()=>{var a;return[e.createElementVNode("span",I,[e.createElementVNode("span",null,e.toDisplayString(((a=r.slots)==null?void 0:a.error)||"Oops something went wrong!"),1),e.createElementVNode("button",{class:"retry",onClick:g[0]||(g[0]=(...C)=>l.emit&&l.emit(...C))},"retry")])]},!0):e.createCommentVNode("",!0)],512))}}),O="",B=u(N,[["__scopeId","data-v-a7077831"]]);s.default=B,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.V3InfiniteLoading={},r.Vue))})(this,function(r,e){"use strict";function y(t,i=null){if(!t)return!1;const o=t.getBoundingClientRect(),n=i?i.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth};return o.bottom>=n.top&&o.top<=n.bottom&&o.right>=n.left&&o.left<=n.right}async function h(t){return t?(await e.nextTick(),t.value instanceof HTMLElement?t.value:t.value?document.querySelector(t.value):null):null}function E(t){let i=`0px 0px ${t.distance}px 0px`;t.top&&(i=`${t.distance}px 0px 0px 0px`);const o=new IntersectionObserver(n=>{n[0].isIntersecting&&(t.firstload&&t.emit(),t.firstload=!0)},{root:t.parentEl,rootMargin:i});return t.infiniteLoading.value&&o.observe(t.infiniteLoading.value),o}async function p(t,i){if(await e.nextTick(),!t.top)return;const o=t.parentEl||document.documentElement;o.scrollTop=o.scrollHeight-i}const v="",u=(t,i)=>{const o=t.__vccOpts||t;for(const[n,c]of i)o[n]=c;return o},w={},S=t=>(e.pushScopeId("data-v-d3e37633"),t=t(),e.popScopeId(),t),x={class:"container"},V=[S(()=>e.createElementVNode("div",{class:"spinner"},null,-1))];function k(t,i){return e.openBlock(),e.createElementBlock("div",x,V)}const I=u(w,[["render",k],["__scopeId","data-v-d3e37633"]]),N={class:"state-error"},b=e.defineComponent({__name:"InfiniteLoading",props:{top:{type:Boolean,default:!1},target:{},distance:{default:0},identifier:{},firstload:{type:Boolean,default:!0},slots:{}},emits:["infinite"],setup(t,{emit:i}){const o=t;let n=null,c=0;const f=e.ref(null),s=e.ref(""),{top:B,firstload:T,distance:$}=o,{identifier:C,target:H}=e.toRefs(o),l={infiniteLoading:f,top:B,firstload:T,distance:$,parentEl:null,emit(){c=(l.parentEl||document.documentElement).scrollHeight,_.loading(),i("infinite",_)}},_={loading(){s.value="loading"},async loaded(){s.value="loaded",await p(l,c),y(f.value,l.parentEl)&&l.emit()},async complete(){s.value="complete",await p(l,c),n==null||n.disconnect()},error(){s.value="error"}};function m(){n==null||n.disconnect(),n=E(l)}return e.watch(C,m),e.onMounted(async()=>{l.parentEl=await h(H),m()}),e.onUnmounted(()=>n==null?void 0:n.disconnect()),(d,g)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"infiniteLoading",ref:f,class:"v3-infinite-loading"},[e.withDirectives(e.createElementVNode("div",null,[e.renderSlot(d.$slots,"spinner",{},()=>[e.createVNode(I)],!0)],512),[[e.vShow,s.value=="loading"]]),s.value=="complete"?e.renderSlot(d.$slots,"complete",{key:0},()=>{var a;return[e.createElementVNode("span",null,e.toDisplayString(((a=d.slots)==null?void 0:a.complete)||"No more results!"),1)]},!0):e.createCommentVNode("",!0),s.value=="error"?e.renderSlot(d.$slots,"error",{key:1,retry:l.emit},()=>{var a;return[e.createElementVNode("span",N,[e.createElementVNode("span",null,e.toDisplayString(((a=d.slots)==null?void 0:a.error)||"Oops something went wrong!"),1),e.createElementVNode("button",{class:"retry",onClick:g[0]||(g[0]=(...O)=>l.emit&&l.emit(...O))},"retry")])]},!0):e.createCommentVNode("",!0)],512))}}),R="",L=u(b,[["__scopeId","data-v-4bdee133"]]);r.default=L,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "v3-infinite-loading",
"version": "1.3.1",
"version": "1.3.2",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Infinite scroller component for vuejs-3",

@@ -30,3 +30,3 @@ <h1 align="center"> vue 3 infinite loading </h1>

import InfiniteLoading from "v3-infinite-loading";
import "v3-infinite-loading/lib/style.css"; //required if you're not going to override default slots
import "v3-infinite-loading/lib/style.css"; // required if you're not going to override default slots

@@ -45,3 +45,3 @@ const app = createApp(App);

import InfiniteLoading from "v3-infinite-loading";
import "v3-infinite-loading/lib/style.css"; //required if you're not going to override default slots
import "v3-infinite-loading/lib/style.css"; // required if you're not going to override default slots
</script>

@@ -59,7 +59,7 @@

<head>
<script src="https://unpkg.com/vue@3.2.37/dist/vue.global.js"></script>
<script src="https://unpkg.com/v3-infinite-loading@1.2.1/lib/v3-infinite-loading.umd.js"></script>
<script src="https://unpkg.com/vue@3.4.38/dist/vue.global.js"></script>
<script src="https://unpkg.com/v3-infinite-loading@1.3.2/lib/v3-infinite-loading.umd.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/v3-infinite-loading@1.2.1/lib/style.css"
href="https://unpkg.com/v3-infinite-loading@1.3.2/lib/style.css"
/>

@@ -87,5 +87,5 @@ </head>

Documentation available on [v3-infinite-loading Netlify](https://vue3-infinite-loading.netlify.com/)
Documentation available on [v3-infinite-loading Netlify](https://vue3-infinite-loading.netlify.app/)
Check out live demo [v3-infinite-loading-demo Netlify](https://vue3-infinite-loading-demo.netlify.com/)
Check out live demo [v3-infinite-loading-demo Netlify](https://vue3-infinite-loading-demo.netlify.app/)

@@ -92,0 +92,0 @@ ## Changelog

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc