# j-LazyLoad

> j-LazyLoad: easy usage; can be used for everything

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 2191ce2af9166b31ea507bb7f4e814004eec086e56520cf68decaaec6eb04217
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- can be used for everything
- vertically position only


__Configuration__:

- `container {String}` a selector as a scrolling container (default: `window`)
- `selector {String}` (__important__) selector for lazy elements
- `exec {String}` a link to method, executed if the lazy element is visible
- `offset {Number}` this value extends the size of scrolling area top/bottom. (default: `50`)

__Methods__:
- `instance.refresh()` refreshes current state

Use it with `<ui-component name="lazyload">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="lazyload" config="selector:.lazyload;exec:lazyload" style="height:1000px">
	<div>SCROLL DOWN</div>
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<div class="lazyload"><img src="https://componentator.com/img/preloader.gif" data-src="https://componentator.com/img/logo.png" /></div>
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
	<br />
</ui-component>

<script>
	function lazyload(el) {
		var img = el.find('img');
		img.attr('src', img.attr('data-src'));
	}
</script>
```
