# j-Pages

> The component is a better alternative to the j-Section component. As a result, you can easily make a multi-page app with dynamic content loading when needed. The result looks very intuitive for mobile

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

The component is a better alternative to the `j-Section` component. As a result, you can easily make a multi-page app with dynamic content loading when needed. The result looks very intuitive for mobile devices or desktop computers.


__Main configuration__:

- `margin {Number/String}` a top margin (default: `0`)
	- `auto` will applied `offset.top` value
- `margintype {String}` can contain `offset` (default) or `position` value
- `delay {Number}` animation delay (default: `220`)
- `parent` {String} optional, a selector to an element with a fixed height (default: `parent` element)
- `scrollbarshadow {Boolean}` enables shadow for the scrollbar (default: `false`)
- `loading {String}` optional, a link to the `function(show_loading {Boolean})`

__Section attribute configuration `data-config`__:

- `if {String}` a condition for displaying of page
- `url {String}` URL address for getting HTML content
- `path {String}` the value will replace `~PATH~` pharses (default: `config.if`)
- `id {String}` the value will replace `~ID~` pharses
- `anim {String}` animation type, supported values `left` (default), `right`, `top` or `bottom`
- `scrollbar {Boolean}` appends a custom scrollbar into the content (default: `true`)
- `scrolltop {Boolean}` enables auto-scroll
- `reload {String}` a link to the `function(el)`, it's executed when the page is displayed
- `hide {String}` a link to the `function(el)`, it's executed when the page is hidden
- `check {String}` a link to the `function(next, el)`
	- `next {Function}` continues with page displaying
- `autofocus {Boolean}` performs autofocus for the current page

Use it with `<ui-component name="pages">`. 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
<style>
	body { padding: 0; margin: 0; overflow: hidden; }
</style>

<ui-component name="pages" path="common.page" config="parent:window">

	<section class="hidden invisible" data-config="if:page1;anim:left">
		<div class="padding">
			<div style="background-color:#F0F0F0;margin:30px auto;padding:30px;max-width:600px;border-radius:10px">
				PAGE 1
			</div>
		</div>
	</section>

	<section class="hidden invisible" data-config="if:page2;anim:right">
		<div class="padding">
			<div style="background-color:#F0F0F0;margin:30px auto;padding:30px;max-width:600px;border-radius:10px">
				PAGE 2
			</div>
		</div>
	</section>

	<section class="hidden invisible" data-config="if:page3;anim:bottom">
		<div class="padding">
			<div style="background-color:#F0F0F0;margin:30px auto;padding:30px;max-width:600px;border-radius:10px">
				PAGE 3
			</div>
		</div>
	</section>
</ui-component>


<script>

	var common = {};

	function togglepage() {

		var val = common.page;

		switch (val) {
			case 'page1':
				val = 'page2';
				break;
			case 'page2':
				val = 'page3';
				break;
			case 'page3':
			default:
				val = 'page1';
				break;
		}

		SET('common.page', val);
	}

	setInterval(togglepage, 2000);
	togglepage();

</script>
```
