# j-InfiniteScroll

> j-InfiniteScroll options: parent, margin, padding, autoscroll, exec

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

__Configuration__:

- `parent {String}` a parent element due to height of container (default: `parent`)
- `margin {Number}` a margin for `height` (default: `0` px)
- `padding {Number}` a bottom scroll padding for performing of reading (default: `50` px)
- `autoscroll {Number}` automatically scrolls container if the content is added (default: `100` px)
- `exec {String}` a link to the method which is executed if the scrollbar is at the end, look into the implementation below:

```javascript
function method_append(next, element, init) {
	// @next {Function(new_content)}
	// @element {jQuery}
	// @init {Boolean} Is the component initialized?

	// element.append(...);
	// or
	next('NEW_HTML_CONTENT_or_RAW_NODE_ELEMENT');
}
```

Use it with `<ui-component name="infinitescroll">`. 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
<div style="width:500px;height:300px;border:1px solid red">
	<ui-component name="infinitescroll" config="exec:add_new_content">
		<div style="height:1000px">Some content</div>
	</ui-component>
</div>

<script>
	function add_new_content(next, el, init) {

		// init
		if (init)
			return;

		setTimeout(function() {
			// el.append(...);
			// or
			next('<div style="height:500px">' + new Date().format('HH:mm:ss') + '</div>');

			// or if the content doesn't exist:
			// next();
		}, 1000);
	}
</script>
```
