svelte-lazy
Advanced tools
Comparing version 0.1.4 to 0.1.5
12
index.js
@@ -790,3 +790,3 @@ (function (global, factory) { | ||
context = this; | ||
args = [event.target.value]; | ||
args = arguments; | ||
if (remaining <= 0 || remaining > wait) { | ||
@@ -817,7 +817,3 @@ if (timeout) { | ||
if (height) { | ||
if (typeof height === 'number') { | ||
node.style.height = height + 'px'; | ||
} else { | ||
node.style.height = height; | ||
} | ||
node.style.height = (typeof height === 'number') ? height + 'px' : height; | ||
} | ||
@@ -831,4 +827,4 @@ | ||
$$invalidate('loaded', loaded = true); | ||
node.style.height = ''; | ||
onload && onload(); | ||
setTimeout(() => node.style.height = 'auto'); | ||
onload && onload(node); | ||
removeListeners(); | ||
@@ -835,0 +831,0 @@ } |
@@ -6,4 +6,5 @@ { | ||
"main": "index.js", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"scripts": { | ||
"test": "rollup -c ./test/rollup.config.js -w", | ||
"build": "rollup -c", | ||
@@ -13,3 +14,4 @@ "prepublishOnly": "npm run build" | ||
"devDependencies": { | ||
"rollup": "^1.11.0", | ||
"rollup": "^1.18.0", | ||
"rollup-plugin-livereload": "^1.0.1", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
@@ -16,0 +18,0 @@ "rollup-plugin-svelte": "^5.0.0", |
@@ -10,7 +10,8 @@ # svelte-lazy | ||
## Usage | ||
```html | ||
import Lazy from 'svelte-lazy'; | ||
<script> | ||
import Lazy from 'svelte-lazy'; | ||
</script> | ||
<Lazy height={500} offset={150}> | ||
<Lazy height={300} offset={150}> | ||
<img alt="" src="https://picsum.photos/id/412/200/300" /> | ||
@@ -28,4 +29,22 @@ </Lazy> | ||
- `fadeOption: Object/Boolean` Default: `{ delay: 0, duration: 400 }`. Option for the fade transition. Set `null/false` to disable. | ||
- `fadeOption: Object` Default: `{ delay: 0, duration: 400 }`. Option for the fade transition. Set `null` to disable. | ||
- `onload: Function` Default: `null`. Callback when the component is loaded. | ||
- `onload: Function (node) => {}` Default: `null`. Fucntion that is called when the component is loaded. | ||
## Demo | ||
See [demo](https://svelte.dev/repl/6d7714fa3cce4909af6c6d187271e0a1?version=3.6.10) here. | ||
<img src="https://github.com/leafOfTree/leafOfTree.github.io/blob/master/svelte-lazy.gif" width="300" height="300" /> | ||
## Development | ||
npm i | ||
npm run test | ||
# Open test/index.html or open a local server | ||
serve test | ||
## Refs | ||
Based on [sveltejs/component-template: A base for building shareable Svelte components](https://github.com/sveltejs/component-template) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53581
49
5
1588