iwmlib/lib/pixi/switch.html

144 lines
5.2 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2019-03-21 09:57:27 +01:00
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2019-03-21 09:57:27 +01:00
<title>PIXI Switch</title>
2019-03-21 09:57:27 +01:00
<link rel="stylesheet" href="../3rdparty/highlight/styles/default.css" />
<link rel="stylesheet" href="../../css/doctest.css" />
2019-03-21 09:57:27 +01:00
<script src="../3rdparty/highlight/highlight.pack.js"></script>
2019-03-21 09:57:27 +01:00
<script src="../../dist/iwmlib.3rdparty.js"></script>
<script src="../../dist/iwmlib.js"></script>
<script src="../../dist/iwmlib.pixi.js"></script>
</head>
<body onload="Doctest.run()">
<h1><a href="../index.html">lib.</a><a href="index.html">pixi.</a>Switch</h1>
<p>A switch is a visual toggle between two mutually exclusive states—on and off.</p>
<p>
<strong>Consider adjusting a switchs appearance to match the style of your app.</strong> If it works well
in your app, change the colors of a switch in its on and off states or use custom imagery to represent the
switch.
</p>
<p>
<strong>Use switches in table rows only.</strong> Switches are intended for use in tables, such as in a list
of settings that can be toggled on and off. If you need similar functionality in a toolbar or navigation
bar, use a button instead, and provide two distinct icons that communicate the states.
</p>
<p>
<strong>Avoid adding labels to describe the values of a switch.</strong> Switches are either on or off.
Providing labels that describe these states is redundant and clutters the interface.
</p>
<p>
<strong>Consider using switches to manage the availability of related interface elements.</strong> Switches
often affect other content onscreen. Enabling the Airplane Mode switch in Settings, for example, disables
certain other settings, such as Cellular and Personal Hotspot. Disabling the Wi-Fi switch in Settings >
Wi-Fi causes available networks and other options to disappear.
</p>
<p>Let's look at some switch examples:</p>
<br />
<canvas id="canvas" class="interactive"></canvas>
<p>What you should see: Many switches with very different styling and behaviour.</p>
<script class="doctest">
const app = new PIXIApp({
view: canvas,
width: 900,
height: 250,
transparent: false
})
.setup()
.run()
2019-03-21 09:57:27 +01:00
let switch1 = new Switch({
x: 10,
y: 20
})
2019-03-21 09:57:27 +01:00
let switch2 = new Switch({
x: 90,
y: 20,
fill: 0xfd355a,
fillActive: 0x5954d3,
controlFill: 0xfecd2d,
controlFillActive: 0xfd413b,
strokeActiveWidth: 4,
controlStrokeActive: 0x50d968,
controlStrokeActiveWidth: 12,
controlStrokeActiveAlpha: 0.8,
tooltip: 'Dies ist ein Switch'
})
2019-03-21 09:57:27 +01:00
let switch3 = new Switch({
x: 170,
y: 20,
width: 100,
height: 40,
fill: 0xfe9727,
fillAlpha: 0.5,
fillActive: 0x5954d3,
stroke: 0x5ec7f8,
strokeWidth: 12,
strokeActive: 0xfd355a,
strokeActiveWidth: 4,
controlFill: 0xfecd2d,
controlFillActive: 0xfd413b,
controlStroke: 0xfd413b,
controlStrokeWidth: 8,
controlStrokeActive: 0x50d968,
controlStrokeActiveWidth: 16,
controlStrokeActiveAlpha: 0.8,
controlRadiusActive: 12,
duration: 3,
durationActive: 1
})
2019-03-21 09:57:27 +01:00
let switch4 = new Switch({
x: 10,
y: 90,
active: true
})
2019-03-21 09:57:27 +01:00
let switch5 = new Switch({
x: 90,
y: 90,
disabled: true
})
2019-03-21 09:57:27 +01:00
let switch6 = new Switch({
x: 170,
y: 90,
active: true,
disabled: true
})
2019-03-21 09:57:27 +01:00
let switch7 = new Switch({
x: 250,
y: 100,
width: 100,
height: 10,
fill: 0xffffff,
fillActive: 0xffffff,
duration: 0.2,
durationActive: 0.1,
controlFill: 0x00ff00,
controlFillActive: 0xff0000,
controlRadius: 15,
controlRadiusActive: 12,
controlStroke: 0x00aa00,
controlStrokeWidth: 3,
controlStrokeActive: 0xaa0000,
controlStrokeActiveWidth: 2,
tooltip: {
container: app.scene,
content: 'Das Gesetz ist der Freund des Schwachen.'
}
})
2019-03-21 09:57:27 +01:00
app.scene.addChild(switch1, switch2, switch3)
app.scene.addChild(switch4, switch5, switch6, switch7)
</script>
</body>
</html>