interactionTemplate
概览
interactionTemplate 复用事件、动画、状态样式和部分 common props,只在 parser 阶段展开,不生成 runtime view。节点通过 interactionRefs 引用后,模板里的 commonProps、stateStyles、events 和 animations 会合并到节点上。
相关文档
字段
Key |
类型 |
默认值 |
是否必填 |
说明 |
|---|---|---|---|---|
|
string |
无 |
是 |
固定为 |
|
string |
无 |
是 |
模板 id |
|
object |
|
否 |
默认 common props;节点本地字段优先 |
|
object |
|
否 |
默认状态样式;节点本地字段优先 |
|
object[] |
|
否 |
追加到节点事件前面 |
|
object[] |
|
否 |
追加到节点动画前面 |
{
"type": "interactionTemplate",
"id": "press.scale",
"commonProps": {"pressLock": false, "pivotX": "50%", "pivotY": "50%"},
"events": [
{"type": "pressed", "effects": [{"type": "startAnimation", "animationId": "press_down"}]},
{"type": "released", "effects": [{"type": "startAnimation", "animationId": "press_up"}]}
],
"animations": [
{"id": "press_down", "trigger": "manual", "property": "scale", "fromMode": "current", "to": 236},
{"id": "press_up", "trigger": "manual", "property": "scale", "fromMode": "current", "to": 256}
]
}