ForgeComponents
en

Components

j-Pages

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

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.

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>