svelte-infinite-loading
Advanced tools
Comparing version 1.2.5 to 1.3.1
@@ -29,2 +29,5 @@ (function (global, factory) { | ||
} | ||
function is_empty(obj) { | ||
return Object.keys(obj).length === 0; | ||
} | ||
function create_slot(definition, ctx, $$scope, fn) { | ||
@@ -113,3 +116,3 @@ if (definition) { | ||
if (!current_component) | ||
throw new Error(`Function called outside component initialization`); | ||
throw new Error('Function called outside component initialization'); | ||
return current_component; | ||
@@ -171,2 +174,3 @@ } | ||
} | ||
set_current_component(null); | ||
dirty_components.length = 0; | ||
@@ -308,3 +312,4 @@ while (binding_callbacks.length) | ||
callbacks: blank_object(), | ||
dirty | ||
dirty, | ||
skip_bound: false | ||
}; | ||
@@ -316,3 +321,3 @@ let ready = false; | ||
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { | ||
if ($$.bound[i]) | ||
if (!$$.skip_bound && $$.bound[i]) | ||
$$.bound[i](value); | ||
@@ -362,8 +367,12 @@ if (ready) | ||
} | ||
$set() { | ||
// overridden by instance, if it has props | ||
$set($$props) { | ||
if (this.$$set && !is_empty($$props)) { | ||
this.$$.skip_bound = true; | ||
this.$$set($$props); | ||
this.$$.skip_bound = false; | ||
} | ||
} | ||
} | ||
/* src\Spinner.svelte generated by Svelte v3.24.0 */ | ||
/* src/Spinner.svelte generated by Svelte v3.29.4 */ | ||
@@ -540,3 +549,3 @@ function add_css() { | ||
$$self.$set = $$props => { | ||
$$self.$$set = $$props => { | ||
if ("spinner" in $$props) $$invalidate(0, spinner = $$props.spinner); | ||
@@ -556,3 +565,3 @@ }; | ||
/* src\InfiniteLoading.svelte generated by Svelte v3.24.0 */ | ||
/* src/InfiniteLoading.svelte generated by Svelte v3.29.4 */ | ||
@@ -569,3 +578,3 @@ const { document: document_1 } = globals; | ||
const get_error_slot_changes = dirty => ({}); | ||
const get_error_slot_context = ctx => ({ attemptLoad: /*attemptLoad*/ ctx[6] }); | ||
const get_error_slot_context = ctx => ({ attemptLoad: /*attemptLoad*/ ctx[7] }); | ||
const get_noMore_slot_changes = dirty => ({}); | ||
@@ -575,4 +584,4 @@ const get_noMore_slot_context = ctx => ({}); | ||
const get_noResults_slot_context = ctx => ({}); | ||
const get_spinner_slot_changes = dirty => ({}); | ||
const get_spinner_slot_context = ctx => ({}); | ||
const get_spinner_slot_changes = dirty => ({ isFirstLoad: dirty & /*isFirstLoad*/ 2 }); | ||
const get_spinner_slot_context = ctx => ({ isFirstLoad: /*isFirstLoad*/ ctx[1] }); | ||
@@ -583,4 +592,4 @@ // (323:1) {#if showSpinner} | ||
let current; | ||
const spinner_slot_template = /*$$slots*/ ctx[12].spinner; | ||
const spinner_slot = create_slot(spinner_slot_template, ctx, /*$$scope*/ ctx[11], get_spinner_slot_context); | ||
const spinner_slot_template = /*#slots*/ ctx[13].spinner; | ||
const spinner_slot = create_slot(spinner_slot_template, ctx, /*$$scope*/ ctx[12], get_spinner_slot_context); | ||
const spinner_slot_or_fallback = spinner_slot || fallback_block_3(ctx); | ||
@@ -605,4 +614,4 @@ | ||
if (spinner_slot) { | ||
if (spinner_slot.p && dirty & /*$$scope*/ 2048) { | ||
update_slot(spinner_slot, spinner_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_spinner_slot_changes, get_spinner_slot_context); | ||
if (spinner_slot.p && dirty & /*$$scope, isFirstLoad*/ 4098) { | ||
update_slot(spinner_slot, spinner_slot_template, ctx, /*$$scope*/ ctx[12], dirty, get_spinner_slot_changes, get_spinner_slot_context); | ||
} | ||
@@ -631,3 +640,3 @@ } else { | ||
// (325:24) | ||
// (325:38) | ||
function fallback_block_3(ctx) { | ||
@@ -670,4 +679,4 @@ let spinner_1; | ||
let current; | ||
const noResults_slot_template = /*$$slots*/ ctx[12].noResults; | ||
const noResults_slot = create_slot(noResults_slot_template, ctx, /*$$scope*/ ctx[11], get_noResults_slot_context); | ||
const noResults_slot_template = /*#slots*/ ctx[13].noResults; | ||
const noResults_slot = create_slot(noResults_slot_template, ctx, /*$$scope*/ ctx[12], get_noResults_slot_context); | ||
const noResults_slot_or_fallback = noResults_slot || fallback_block_2(); | ||
@@ -692,4 +701,4 @@ | ||
if (noResults_slot) { | ||
if (noResults_slot.p && dirty & /*$$scope*/ 2048) { | ||
update_slot(noResults_slot, noResults_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_noResults_slot_changes, get_noResults_slot_context); | ||
if (noResults_slot.p && dirty & /*$$scope*/ 4096) { | ||
update_slot(noResults_slot, noResults_slot_template, ctx, /*$$scope*/ ctx[12], dirty, get_noResults_slot_changes, get_noResults_slot_context); | ||
} | ||
@@ -714,3 +723,3 @@ } | ||
// (333:26) No results :( | ||
// (333:26) No results :( | ||
function fallback_block_2(ctx) { | ||
@@ -736,4 +745,4 @@ let t; | ||
let current; | ||
const noMore_slot_template = /*$$slots*/ ctx[12].noMore; | ||
const noMore_slot = create_slot(noMore_slot_template, ctx, /*$$scope*/ ctx[11], get_noMore_slot_context); | ||
const noMore_slot_template = /*#slots*/ ctx[13].noMore; | ||
const noMore_slot = create_slot(noMore_slot_template, ctx, /*$$scope*/ ctx[12], get_noMore_slot_context); | ||
const noMore_slot_or_fallback = noMore_slot || fallback_block_1(); | ||
@@ -758,4 +767,4 @@ | ||
if (noMore_slot) { | ||
if (noMore_slot.p && dirty & /*$$scope*/ 2048) { | ||
update_slot(noMore_slot, noMore_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_noMore_slot_changes, get_noMore_slot_context); | ||
if (noMore_slot.p && dirty & /*$$scope*/ 4096) { | ||
update_slot(noMore_slot, noMore_slot_template, ctx, /*$$scope*/ ctx[12], dirty, get_noMore_slot_changes, get_noMore_slot_context); | ||
} | ||
@@ -780,3 +789,3 @@ } | ||
// (341:23) No more data :) | ||
// (341:23) No more data :) | ||
function fallback_block_1(ctx) { | ||
@@ -802,4 +811,4 @@ let t; | ||
let current; | ||
const error_slot_template = /*$$slots*/ ctx[12].error; | ||
const error_slot = create_slot(error_slot_template, ctx, /*$$scope*/ ctx[11], get_error_slot_context); | ||
const error_slot_template = /*#slots*/ ctx[13].error; | ||
const error_slot = create_slot(error_slot_template, ctx, /*$$scope*/ ctx[12], get_error_slot_context); | ||
const error_slot_or_fallback = error_slot || fallback_block(ctx); | ||
@@ -824,4 +833,4 @@ | ||
if (error_slot) { | ||
if (error_slot.p && dirty & /*$$scope*/ 2048) { | ||
update_slot(error_slot, error_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_error_slot_changes, get_error_slot_context); | ||
if (error_slot.p && dirty & /*$$scope*/ 4096) { | ||
update_slot(error_slot, error_slot_template, ctx, /*$$scope*/ ctx[12], dirty, get_error_slot_changes, get_error_slot_context); | ||
} | ||
@@ -846,3 +855,3 @@ } | ||
// (349:36) Oops, something went wrong :( | ||
// (349:36) Oops, something went wrong :( | ||
function fallback_block(ctx) { | ||
@@ -858,3 +867,3 @@ let t0; | ||
c() { | ||
t0 = text("Oops, something went wrong :(\r\n\t\t\t\t"); | ||
t0 = text("Oops, something went wrong :(\n\t\t\t\t"); | ||
br = element("br"); | ||
@@ -873,3 +882,3 @@ t1 = space(); | ||
if (!mounted) { | ||
dispose = listen(button, "click", /*attemptLoad*/ ctx[6]); | ||
dispose = listen(button, "click", /*attemptLoad*/ ctx[7]); | ||
mounted = true; | ||
@@ -896,6 +905,6 @@ } | ||
let current; | ||
let if_block0 = /*showSpinner*/ ctx[2] && create_if_block_3$1(ctx); | ||
let if_block1 = /*showNoResults*/ ctx[4] && create_if_block_2$1(ctx); | ||
let if_block2 = /*showNoMore*/ ctx[5] && create_if_block_1$1(ctx); | ||
let if_block3 = /*showError*/ ctx[3] && create_if_block$1(ctx); | ||
let if_block0 = /*showSpinner*/ ctx[3] && create_if_block_3$1(ctx); | ||
let if_block1 = /*showNoResults*/ ctx[5] && create_if_block_2$1(ctx); | ||
let if_block2 = /*showNoMore*/ ctx[6] && create_if_block_1$1(ctx); | ||
let if_block3 = /*showError*/ ctx[4] && create_if_block$1(ctx); | ||
@@ -923,11 +932,11 @@ return { | ||
if (if_block3) if_block3.m(div, null); | ||
/*div_binding*/ ctx[13](div); | ||
/*div_binding*/ ctx[14](div); | ||
current = true; | ||
}, | ||
p(ctx, [dirty]) { | ||
if (/*showSpinner*/ ctx[2]) { | ||
if (/*showSpinner*/ ctx[3]) { | ||
if (if_block0) { | ||
if_block0.p(ctx, dirty); | ||
if (dirty & /*showSpinner*/ 4) { | ||
if (dirty & /*showSpinner*/ 8) { | ||
transition_in(if_block0, 1); | ||
@@ -951,7 +960,7 @@ } | ||
if (/*showNoResults*/ ctx[4]) { | ||
if (/*showNoResults*/ ctx[5]) { | ||
if (if_block1) { | ||
if_block1.p(ctx, dirty); | ||
if (dirty & /*showNoResults*/ 16) { | ||
if (dirty & /*showNoResults*/ 32) { | ||
transition_in(if_block1, 1); | ||
@@ -975,7 +984,7 @@ } | ||
if (/*showNoMore*/ ctx[5]) { | ||
if (/*showNoMore*/ ctx[6]) { | ||
if (if_block2) { | ||
if_block2.p(ctx, dirty); | ||
if (dirty & /*showNoMore*/ 32) { | ||
if (dirty & /*showNoMore*/ 64) { | ||
transition_in(if_block2, 1); | ||
@@ -999,7 +1008,7 @@ } | ||
if (/*showError*/ ctx[3]) { | ||
if (/*showError*/ ctx[4]) { | ||
if (if_block3) { | ||
if_block3.p(ctx, dirty); | ||
if (dirty & /*showError*/ 8) { | ||
if (dirty & /*showError*/ 16) { | ||
transition_in(if_block3, 1); | ||
@@ -1044,3 +1053,3 @@ } | ||
if (if_block3) if_block3.d(); | ||
/*div_binding*/ ctx[13](null); | ||
/*div_binding*/ ctx[14](null); | ||
} | ||
@@ -1196,2 +1205,3 @@ }; | ||
function instance$1($$self, $$props, $$invalidate) { | ||
let { $$slots: slots = {}, $$scope } = $$props; | ||
const dispatch = createEventDispatcher(); | ||
@@ -1211,3 +1221,3 @@ let { distance = 100 } = $$props; | ||
loaded: async () => { | ||
$$invalidate(14, isFirstLoad = false); | ||
$$invalidate(1, isFirstLoad = false); | ||
@@ -1236,3 +1246,3 @@ if (direction === "top") { | ||
$$invalidate(15, status = STATUS.READY); | ||
$$invalidate(14, isFirstLoad = true); | ||
$$invalidate(1, isFirstLoad = true); | ||
scrollBarStorage.remove(scrollParent); | ||
@@ -1359,18 +1369,16 @@ scrollParent.addEventListener("scroll", scrollHandler, thirdEventArg); | ||
let { $$slots = {}, $$scope } = $$props; | ||
function div_binding($$value) { | ||
binding_callbacks[$$value ? "unshift" : "push"](() => { | ||
thisElement = $$value; | ||
$$invalidate(1, thisElement); | ||
$$invalidate(2, thisElement); | ||
}); | ||
} | ||
$$self.$set = $$props => { | ||
if ("distance" in $$props) $$invalidate(7, distance = $$props.distance); | ||
$$self.$$set = $$props => { | ||
if ("distance" in $$props) $$invalidate(8, distance = $$props.distance); | ||
if ("spinner" in $$props) $$invalidate(0, spinner = $$props.spinner); | ||
if ("direction" in $$props) $$invalidate(8, direction = $$props.direction); | ||
if ("forceUseInfiniteWrapper" in $$props) $$invalidate(9, forceUseInfiniteWrapper = $$props.forceUseInfiniteWrapper); | ||
if ("identifier" in $$props) $$invalidate(10, identifier = $$props.identifier); | ||
if ("$$scope" in $$props) $$invalidate(11, $$scope = $$props.$$scope); | ||
if ("direction" in $$props) $$invalidate(9, direction = $$props.direction); | ||
if ("forceUseInfiniteWrapper" in $$props) $$invalidate(10, forceUseInfiniteWrapper = $$props.forceUseInfiniteWrapper); | ||
if ("identifier" in $$props) $$invalidate(11, identifier = $$props.identifier); | ||
if ("$$scope" in $$props) $$invalidate(12, $$scope = $$props.$$scope); | ||
}; | ||
@@ -1385,18 +1393,18 @@ | ||
if ($$self.$$.dirty & /*status*/ 32768) { | ||
$$invalidate(2, showSpinner = status === STATUS.LOADING); | ||
$$invalidate(3, showSpinner = status === STATUS.LOADING); | ||
} | ||
if ($$self.$$.dirty & /*status*/ 32768) { | ||
$$invalidate(3, showError = status === STATUS.ERROR); | ||
$$invalidate(4, showError = status === STATUS.ERROR); | ||
} | ||
if ($$self.$$.dirty & /*status, isFirstLoad*/ 49152) { | ||
$$invalidate(4, showNoResults = status === STATUS.COMPLETE && isFirstLoad); | ||
if ($$self.$$.dirty & /*status, isFirstLoad*/ 32770) { | ||
$$invalidate(5, showNoResults = status === STATUS.COMPLETE && isFirstLoad); | ||
} | ||
if ($$self.$$.dirty & /*status, isFirstLoad*/ 49152) { | ||
$$invalidate(5, showNoMore = status === STATUS.COMPLETE && !isFirstLoad); | ||
if ($$self.$$.dirty & /*status, isFirstLoad*/ 32770) { | ||
$$invalidate(6, showNoMore = status === STATUS.COMPLETE && !isFirstLoad); | ||
} | ||
if ($$self.$$.dirty & /*forceUseInfiniteWrapper, mounted*/ 66048) { | ||
if ($$self.$$.dirty & /*forceUseInfiniteWrapper, mounted*/ 66560) { | ||
// Watch forceUseInfiniteWrapper and mounted | ||
@@ -1406,3 +1414,3 @@ (updateScrollParent()); | ||
if ($$self.$$.dirty & /*identifier, mounted*/ 66560) { | ||
if ($$self.$$.dirty & /*identifier, mounted*/ 67584) { | ||
// Watch identifier and mounted | ||
@@ -1415,2 +1423,3 @@ (identifierUpdated()); | ||
spinner, | ||
isFirstLoad, | ||
thisElement, | ||
@@ -1427,3 +1436,3 @@ showSpinner, | ||
$$scope, | ||
$$slots, | ||
slots, | ||
div_binding | ||
@@ -1439,7 +1448,7 @@ ]; | ||
init(this, options, instance$1, create_fragment$1, safe_not_equal, { | ||
distance: 7, | ||
distance: 8, | ||
spinner: 0, | ||
direction: 8, | ||
forceUseInfiniteWrapper: 9, | ||
identifier: 10 | ||
direction: 9, | ||
forceUseInfiniteWrapper: 10, | ||
identifier: 11 | ||
}); | ||
@@ -1446,0 +1455,0 @@ } |
{ | ||
"name": "svelte-infinite-loading", | ||
"version": "1.2.5", | ||
"version": "1.3.1", | ||
"description": "An infinite scroll component for Svelte apps", | ||
"svelte": "src/index.js", | ||
"main": "dist/svelte-infinite-loading.js", | ||
"module": "dist/svelte-infinite-loading.mjs", | ||
"main": "dist/svelte-infinite-loading.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"dev": "rollup -cw", | ||
"prepublishOnly": "npm run build", | ||
"test": "node test/runner.js", | ||
"test:browser": "npm run build && serve test/public", | ||
"pretest": "npm run build", | ||
"lint": "eslint src/**" | ||
"lint": "eslint src/** test/**", | ||
"test": "jest test", | ||
"test:watch": "npm run test -- --watch", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"eslint": "^7.5.0", | ||
"@testing-library/jest-dom": "^5.11.5", | ||
"@testing-library/svelte": "^3.0.0", | ||
"eslint": "^7.12.0", | ||
"eslint-plugin-svelte3": "^2.7.3", | ||
"port-authority": "^1.0.5", | ||
"puppeteer": "^5.2.1", | ||
"rollup": "^2.23.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"jest": "^26.6.1", | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-svelte": "^5.2.3", | ||
"sirv": "^0.2.2", | ||
"svelte": "^3.0.0-beta.2", | ||
"tap-diff": "^0.1.1", | ||
"tap-dot": "^2.0.0", | ||
"tape-modern": "^1.1.1" | ||
"svelte": "^3.29.4", | ||
"svelte-jester": "^1.1.5" | ||
}, | ||
"files": [ | ||
"src", | ||
"dist" | ||
"dist", | ||
"types" | ||
], | ||
@@ -36,0 +33,0 @@ "keywords": [ |
@@ -12,2 +12,3 @@ <p align="center"><img src="https://raw.githubusercontent.com/Skayo/svelte-infinite-loading/master/assets/InfiniteLogo.svg" alt="InfiniteLogo" width="225"></p> | ||
<a href="#features">Features</a> • | ||
<a href="#installation">Installation</a> • | ||
<a href="#documentation">Documentation</a> • | ||
@@ -31,3 +32,3 @@ <a href="#examples">Examples</a> • | ||
## Install | ||
## Installation | ||
@@ -47,3 +48,3 @@ > If you're using this component in a Sapper application, make sure to install the package to `devDependencies`! | ||
Or, what I would recommend, with [pnpm](https://pnpm.js.org/): | ||
With [pnpm](https://pnpm.js.org/) (recommended): | ||
```shell | ||
@@ -54,3 +55,11 @@ $ npm i -g pnpm | ||
From CDN (via [unpkg](https://unpkg.com/)): | ||
```html | ||
<!-- UMD --> | ||
<script src="https://unpkg.com/svelte-infinite-loading@^1/dist/svelte-infinite-loading.js"></script> | ||
<!-- ES Module --> | ||
<script src="https://unpkg.com/svelte-infinite-loading@^1/dist/svelte-infinite-loading.mjs"></script> | ||
``` | ||
## Examples / Demo | ||
@@ -57,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
124060
10
9
2715
78