Super tiny, loadable component for SvelteJS with blackjack and data preloading.
npm install svelte-viewpoint 
- Static & dynamic components.
- loading placeholder component with delay.
- waiting placeholder component after timeout.
- error component.
- Proxes any additional props to target component.
- Preloads target component data using Sapper-like preload function in context of module.
``bash`
npm i svelte-viewpoint --save-dev
`bash`
yarn add svelte-viewpoint
CDN: UNPKG | jsDelivr (available as window.Viewpoint)
`html
`
`html
`
`html
Wait for a few seconds, please...
`
`html
`
Define preload in UserProfile.svelte:
`html
`
| Name | Type | Description | Required | Default |
| --- | --- | --- | --- | --- |
| component | Function | Returns target component. | No | null |delay
| | Number | Delay in ms before the loading component is shown. | No | 200 |timeout
| | Number | Timeout in ms before the waiting component is shown. If not defined or 0 waiting component won't be shown. | No | 0 |abort
| | Number | Timeout in ms before target component loading will be aborted. If not defined or 0 loading won't be aborted until the error. | No | 0 |preloading
| | Boolean | Activates data preloading. | No | true |
— elements to be placed on waiting
- loading — elements to be placed on loading
- error` — elements to be placed on errorMIT © PaulMaly