ForgeComponents
en

Components

j-VirtualWire

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

This is a very special UI component that can move elements from element to another element according to the selector and the value of the path. Look to the example for understanding.

  • selector {String} a selector for wires (default: .virtualwire)
  • delay {Number} a delay in milliseconds for movement of elements (default: 10)
  • repeat {Number} a repeat delay for obtaining of element (default: 50 ms)
  • max {Number} a maximum count for repeating (default: 100)

Use it with <ui-component name="virtualwire">. 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
<div class="b">Virtual Wire Container:</div>
<ui-component name="virtualwire" path="common.page"></ui-component>

<hr />

<!-- YOU CAN HIDE THE ELEMENTS BELOW BY ADDING "hidden" CLASS -->
<div class="virtualwire" data-if="users">
	<div>USERS</div>
</div>

<div class="virtualwire" data-if="products" data-in="products_in" data-out="products_out">
	<div>PRODUCTS</div>
</div>

<script>

	var common = {};

	setInterval(function() {
		switch (common.page) {
			case 'users':
				SET('common.page', 'products');
				break;
			case 'products':
				NULL('common.page');
				break;
			default:
				SET('common.page', 'users');
				break;
		}
	}, 2000);

	function products_out() {
		console.log('products_out');
	}

	function products_in() {
		console.log('products_in');
	}

</script>