# Component-specified Command

作用在专门组件可使用的 Command 类型

# Scroll

实现 ScrollView 和 List 的窗口滑动,将 List 当前展现的窗口视图向上或者向下滑动指定的距离

# 消息样例

 {
    "type": "Scroll",
    "componentId": "{{STRING}}",
    "delay": {{INTEGER}},
    "dWhen": "{{STRING}}",
    "duration": {{INTEGER}},
    "distance": "{{STRING}}"
 }

# 参数说明

  • type
    • 固定 Scroll
  • componentId
    • 绑定的组件 id
  • (optional) delay
    • 指令在端上的延迟执行时间,单位毫秒,默认为 0
  • (optional) dWhen
  • (optional) duration
    • 滚动动画持续时间,单位毫秒,默认 500 毫秒
  • distance
    • 每次窗口滑动的距离,如 20dp 或者 10%。负值如 -20dp 或者 -10%,表示向下滑动

# ScrollToIndex

将当前的 List 视图滑动到指定 item 所在的列表项处, index 表示列表项的序号

# 消息样例

{
    "type": "ScrollToIndex",
    "componentId": "{{STRING}}",
    "delay": {{INTEGER}},
    "dWhen": "{{STRING}}",
    "duration": {{INTEGER}},
    "index": {{INTEGER}},
    "align": "{{ENUM}}"
}

# 参数说明

  • type
    • 固定 ScrollToIndex
  • componentId
    • 绑定的组件 id
  • (optional) delay
    • 指令在端上的延迟执行时间,单位毫秒,默认为 0
  • (optional) dWhen
  • (optional) duration
    • 滚动动画持续时间,单位毫秒,默认 500 毫秒
  • index
    • 指定的 item 的 index, 如有 N 个 item 取值 0 到 N-1
  • align
    • 枚举, 取值如下
    • first 指定的 index 处于屏幕顶部第一个或者最左边位置
    • center 指定的 index 处于屏幕中间位置
    • last 指定的 index 处于屏幕底部或者最右边位置

# ScrollToElement

将当前的列表视图(ScrollView、List)滑动到指定 item 所在的列表项处, targetComponentId 表示列表的对应目标子项

# 消息样例

{
    "type": "ScrollToElement",
    "componentId": "{{STRING}}",
    "delay": {{INTEGER}},
    "dWhen": "{{STRING}}",
    "duration": {{INTEGER}},
    "targetComponentId": "{{STRING}}",
    "align": "{{ENUM}}"
}

# 参数说明

  • type
    • 固定 ScrollToElement
  • componentId
    • 绑定的组件 id
  • (optional) delay
    • 指令在端上的延迟执行时间,单位毫秒,默认为 0
  • (optional) dWhen
  • (optional) duration
    • 滚动动画持续时间,单位毫秒,默认 500 毫秒
  • targetComponentId
    • 指定的 item 的 componentId, 需明确指明
  • align
    • 枚举, 取值如下
    • first 指定的目标 item 处于屏幕顶部第一个或者最左边位置
    • center 指定的目标 item 处于屏幕中间位置
    • last 指定的目标 item 处于屏幕底部或者最右边位置

# AutoPage

实现 pager 组件的的自动翻页功能, 最终停留在最后的页面

# 消息样例

{
    "type": "AutoPage",
    "componentId": "{{STRING}}",
    "delay": {{INTEGER}},
    "dWhen": "{{STRING}}",
    "durationInMillisecond": {{INTEGER}}
}

# 参数说明

  • type
    • 固定 AutoPage
  • componentId
    • 绑定的组件 id
  • (optional) delay
    • 指令在端上的延迟执行时间,单位毫秒,默认为 0
  • (optional) dWhen
  • durationInMillisecond
    • 页面翻页时切换的时间间隔,单位毫秒

# SetPage

将 pager 组件的视图切换到指定目录页面,index 值表示 pager 的页面序号

# 消息样例

{
    "type": "SetPage",
    "componentId": "{{STRING}}",
    "delay": {{INTEGER}},
    "position": "{{ENUM}}",
    "value": {{INTEGER}}
}

# 参数说明

  • type
    • 固定 SetPage
  • componentId
    • 绑定的组件 id
  • (optional) delay
    • 指令在端上的延迟执行时间,单位毫秒,默认为 0
  • (optional) dWhen
  • position
    • 枚举, 取值如下
    • relative 相对位置
    • 以当前页 index 作为参考位置,当 index 取正值往后翻页, 当 value 取负值往前翻页, 举例: 当前页面 index = 11 如 value = 2, 翻页后 index = 13, 如 value = -2, 翻页后 index = 9
    • absolute 绝对位置
    • 当 value 取正值,从 index = 0 作为参考位置往后翻页,当 value 取负值, 从 index = N-1 作为参考往前翻页, 如 N = 10, value = 2, 翻页后的 index = 2, 如 index = -2, 翻页后的 index = 7
  • value
    • 翻页步长, 假如有 N 个页, 取值 0 到 N-1