DragReveal data
A slider that drags itself from one state to another. The card wipes from the first label to the second while a percentage and a ring follow and the corners round off: one piece of state (drag) drives every part.
Props#
| Prop | Type | Default | Notes |
|---|---|---|---|
| before | string | "RAW" | |
| after | string | "READY" | |
| delay | number (0 to 20) | 0.8 | seconds after it starts before the drag begins |
| seconds | number (0.2 to 10) | 2.4 | how long the drag takes |
| w | number (200 to 1000) | 760 | |
| h | number (200 to 1300) | 820 | |
| color | color | "accent>accent2" | |
| tilt | number (-20 to 20) | 3 | degrees the card leans mid-drag |
* required. Every node also takes the common props: id, motion, start, place, scale, rotate, opacity, w, h. A colour is a palette name, never a value.
Parts#
Named parts can be restyled from outside without making a new component: "parts": { "root": { … } }.
| Part | Is a |
|---|---|
| root | box |
| percent | text |
| ring | shape |
| card | box |
| before | text |
| after | box |
| fill | shape |
| knob | shape |
Example#
{"el": "DragReveal", "before": "RAW", "after": "READY"}How it is made#
This component is plain data. Its whole definition is the tree below: copy it into a scene's components list under a new name to make your own version. See Custom components.
{
"el": "box",
"gap": 46,
"align": "center",
"children": [
{
"el": "box",
"dir": "row",
"gap": 30,
"align": "center",
"children": [
{
"el": "text",
"id": "percent",
"text": "{round(drag*100)}%",
"size": 150,
"weight": 800
},
{
"el": "shape",
"id": "ring",
"kind": "ring",
"w": 120,
"h": 120,
"stroke": "accent",
"strokeW": 13,
"progress": "=drag"
}
]
},
{
"el": "box",
"id": "card",
"dir": "stack",
"w": "$w",
"h": "$h",
"radius": "=14+90*drag",
"clip": true,
"fill": "rgba(128,128,140,.28)",
"motion": [
{
"do": "drive",
"pose": {"rotate": "=-tilt*sin(drag*pi)", "scale": "=1+0.03*sin(drag*pi)"}
}
],
"children": [
{
"el": "text",
"id": "before",
"text": "$before",
"size": 96,
"weight": 800,
"color": "muted"
},
{
"el": "box",
"id": "after",
"dir": "stack",
"w": "$w",
"h": "$h",
"fill": "$color",
"motion": [{"do": "drive", "pose": {"clipR": "=100-100*drag"}}],
"children": [{"el": "text", "text": "$after", "size": 96, "weight": 800, "color": "white"}]
}
]
},
{
"el": "box",
"dir": "stack",
"w": "$w",
"h": 70,
"children": [
{
"el": "box",
"w": "$w",
"h": 22,
"radius": 11,
"fill": "rgba(128,128,140,.28)",
"align": "start",
"clip": true,
"children": [
{
"el": "shape",
"id": "fill",
"kind": "rect",
"w": "=w*drag",
"h": 22,
"fill": "accent"
}
]
},
{
"el": "shape",
"id": "knob",
"kind": "circle",
"w": 66,
"fill": "paper",
"stroke": "accent",
"strokeW": 9,
"glow": "accent",
"place": [0, 0.5],
"motion": [{"do": "drive", "pose": {"x": "=w*drag"}}]
}
]
}
]
}