ForgeComponents
en

Components

j-LazyLoad

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • 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.

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>