提交 7ed5f4ca 编写于 作者: H HelloCrease 提交者: LiAn
上级 798f9610
......@@ -11,71 +11,71 @@ Bind different types of gesture events to components and set response methods fo
Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component.
| Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- |
| gesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to bind.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting.|
| priorityGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to preferentially recognize.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting.<br>By default, a component recognizes gestures bound through **gesture**. When **priorityGesture** is configured for its parent component, the component preferentially recognizes gestures bound through **priorityGesture**.|
| parallelGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br>- **gesture**: type of the gesture to bind. <br>- **mask**: event response setting.<br>The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent component and child components can be triggered, thereby implementing a bubbling effect.|
| Name | Type | Default Value | Description |
| --------------- | ---------------------------------------- | --------------------------------------- | ---------------------------------------- |
| gesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to bind.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting. |
| priorityGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to preferentially recognize.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting.<br>By default, a component recognizes gestures bound through **gesture**. When **priorityGesture** is configured for its parent component, the component preferentially recognizes gestures bound through **priorityGesture**. |
| parallelGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br>- **gesture**: type of the gesture to bind. <br>- **mask**: event response setting.<br>The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent component and child components can be triggered, thereby implementing a bubbling effect. |
## GestureType
| Name| Description|
| -------- | -------- |
| [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture.|
| [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture.|
| [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen.|
| [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture.|
| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture.|
| [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher.|
| [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported.|
| Name | Description |
| ---------------------------------------- | ---------------------------------------- |
| [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture. |
| [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture. |
| [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen. |
| [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture. |
| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture. |
| [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher. |
| [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. |
## GestureMask
| Name| Description|
| -------- | -------- |
| Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence.|
| IgnoreInternal | The gestures of child components are ignored. Only the gestures of the current component are recognized.<br>However, the built-in gestures of the child components are not ignored. For example, when the child component is a **\<List>** component, the built-in sliding gestures can still be triggered.|
| Name | Description |
| -------------- | ---------------------------------------- |
| Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence. |
| IgnoreInternal | The gestures of child components are ignored. Only the gestures of the current component are recognized.<br>However, the built-in gestures of the child components are not ignored. For example, when the child component is a **\<List>** component, the built-in sliding gestures can still be triggered. |
## Gesture Response Event
The component binds gesture objects of different **GestureType**s through gesture events. Each gesture object provides gesture-related information in the gesture response event. In the following example, the **TapGesture** object provides gesture-related information in the **onAction** event. For details about the event definitions of other gestures, see the corresponding gesture sections. To bind multiple gestures, use [combined gestures](ts-combined-gestures.md).
- TapGesture
| Name| Description|
| -------- | -------- |
| onAction((event?:GestureEvent) =&gt; void) | Callback invoked when a tap gesture is recognized.|
| Name | Description |
| ---------------------------------------- | ---------------------------------------- |
| onAction((event?:GestureEvent) =&gt; void) | Callback invoked when a tap gesture is recognized. |
## GestureEvent
| Name| Type| Description|
| -------- | -------- | -------- |
| Name | Type | Description |
| ----------------------- | ---------------------------------------- | ---------------------------------------- |
| repeat | boolean | Whether the event is triggered repeatedly. This attribute is used for the **LongPressGesture** event. |
| offsetX | number | Offset of the gesture event on the x-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means panning from left to right, and a negative value means the opposite. |
| offsetY | number | Offset of the gesture event on the y-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means panning from top to bottom, and a negative value means the opposite. |
| angle | number | Rotation angle for the **RotationGesture** event;<br>angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.<br>**NOTE**<br>Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees.|
| scale | number | Scale ratio. This attribute is used for the **PinchGesture** event.|
| angle | number | Rotation angle for the **RotationGesture** event;<br>angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.<br>**NOTE**<br>Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees. |
| scale | number | Scale ratio. This attribute is used for the **PinchGesture** event. |
| pinchCenterX | number | X-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. |
| pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. |
| speed<sup>8+</sup> | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event.|
| fingerList<sup>8+</sup> | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event, which is used for the **LongPressGesture** and **TapGesture** events.|
| timestamp<sup>8+</sup> | number | Timestamp of the event.|
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event.|
| source<sup>8+</sup> | [SourceType](#sourcetype) | Event input device.|
| speed<sup>8+</sup> | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event. |
| fingerList<sup>8+</sup> | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event, which is used for the **LongPressGesture** and **TapGesture** events. |
| timestamp<sup>8+</sup> | number | Timestamp of the event. |
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event. |
| source<sup>8+</sup> | [SourceType](#sourcetype) | Event input device. |
## SourceType
| Name| Description|
| -------- | -------- |
| Unknown | Unknown device type.|
| Mouse | Mouse.|
| TouchScreen | Touchscreen.|
| Name | Description |
| ----------- | -------------------- |
| Unknown | Unknown device type. |
| Mouse | Mouse. |
| TouchScreen | Touchscreen. |
## FingerInfo
| Name| Type| Description|
| -------- | -------- | -------- |
| id | number | Index of a finger.|
| globalX | number | X-coordinate relative to the upper left corner of the application window.|
| globalY | number | Y-coordinate relative to the upper left corner of the application window.|
| localX | number | X-coordinate relative to the upper left corner of the current component.|
| localY | number | Y-coordinate relative to the upper left corner of the current component.|
| Name | Type | Description |
| ------- | ------ | ---------------------------------------- |
| id | number | Index of a finger. |
| globalX | number | X-coordinate relative to the upper left corner of the application window. |
| globalY | number | Y-coordinate relative to the upper left corner of the application window. |
| localX | number | X-coordinate relative to the upper left corner of the current component. |
| localY | number | Y-coordinate relative to the upper left corner of the current component. |
## Example
......
......@@ -139,4 +139,4 @@ export default {
}
```
![zh-cn_image1](figures/zh-cn_image1.PNG)
\ No newline at end of file
![zh-cn_image1](figures/zh-cn_image1.png)
\ No newline at end of file
......@@ -6,11 +6,10 @@
>
> 该组件从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
构造参数type为"surface"时不支持。
## 子组件
构造参数type为"surface"时不支持。\
从API version 9开始,构造参数type为"component"时可以包含子组件。
## 接口
......@@ -20,7 +19,7 @@
**参数:**
| 参数名 | 参数类型 | 必填 | 描述 |
| --------- | ------ | ---- | ----- |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| id | string | 是 | 组件的唯一标识,支持最大的字符串长度128。 |
| type | string | 是 | 用于指定XComponent组件类型,可选值为:<br/>-"surface":用于EGL/OpenGLES和媒体数据写入,组件内容单独送显,直接合成到屏幕。<br/>-"component"<sup>9+</sup> :XComponent将变成一个容器组件,并可在其中执行非UI逻辑以动态加载显示内容。 |
| libraryname | string | 否 | 应用Native层编译输出动态库名称,仅XComponent类型为"surface"时有效。 |
......@@ -46,7 +45,7 @@
## 事件
仅type为"surface"时以下事件有效。不支持[通用事件和手势](./Readme-CN.md)
仅type为"surface"时以下事件有效。不支持[通用事件](ts-universal-events-click.md)[手势](ts-gesture-settings.md)
### onLoad
......@@ -57,7 +56,7 @@ onLoad(callback: (event?: object) => void )
**参数:**
| 参数名 | 参数类型 | 必填 | 描述 |
| ------------- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ---------------------------------------- |
| event | object | 否 | 获取XComponent实例对象的context,context上挂载的方法由开发者在c++层定义。 |
### onDestroy
......
......@@ -23,8 +23,8 @@ Video(value: {src?: string | Resource, currentProgressRate?: number | string | P
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| src | string \| [Resource](ts-types.md) | 否 | 视频播放源的路径,支持本地视频路径和网络路径。<br>支持在resources下面的video或rawfile文件夹里放置媒体资源。<br>支持dataability://的路径前缀,用于访问通过Data Ability提供的视频路径,具体路径信息详见[DataAbility说明](../../ability/fa-dataability.md)<br/>**说明:**<br/>视频支持的格式是:mp4、mkv、webm、TS。 |
| ------------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| src | string \| [Resource](ts-types.md) | 否 | 视频播放源的路径,支持本地视频路径和网络路径。<br>支持在resources下面的video或rawfile文件夹里放置媒体资源。<br>支持dataability://的路径前缀,用于访问通过Data Ability提供的视频路径,具体路径信息详见[DataAbility说明](../../application-models/dataability-overview.md)<br/>**说明:**<br/>视频支持的格式是:mp4、mkv、webm、TS。 |
| currentProgressRate | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;PlaybackSpeed<sup>8+</sup> | 否 | 视频播放倍速。<br/>**说明:**<br/>number取值仅支持:0.75,1.0,1.25,1.75,2.0。<br/>默认值:1.0 \| PlaybackSpeed.Speed_Forward_1_00_X |
| previewUri | string&nbsp;\|&nbsp;PixelMap<sup>8+</sup>&nbsp;\|&nbsp;[Resource](ts-types.md) | 否 | 视频未播放时的预览图片路径。 |
| controller | [VideoController](#videocontroller) | 否 | 设置视频控制器。 |
......@@ -44,7 +44,7 @@ Video(value: {src?: string | Resource, currentProgressRate?: number | string | P
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
| 名称 | 参数类型 | 描述 |
| --------- | ---------------------------------------- | ----------------------------------------------- |
| --------- | ---------------------------------------- | ---------------------------- |
| muted | boolean | 是否静音。<br/>默认值:false |
| autoPlay | boolean | 是否自动播放。<br/>默认值:false |
| controls | boolean | 控制视频播放的控制栏是否显示。<br/>默认值:true |
......@@ -56,7 +56,7 @@ Video(value: {src?: string | Resource, currentProgressRate?: number | string | P
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
| 名称 | 功能描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ---------------------------------------- | ---------------------------------------- |
| onStart(event:()&nbsp;=&gt;&nbsp;void) | 播放时触发该事件。 |
| onPause(event:()&nbsp;=&gt;&nbsp;void) | 暂停时触发该事件。 |
| onFinish(event:()&nbsp;=&gt;&nbsp;void) | 播放结束时触发该事件。 |
......@@ -107,7 +107,7 @@ setCurrentTime(value: number)
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------ | -------- | ---- | --------------------------- |
| ----- | ------ | ---- | -------------- |
| value | number | 是 | 视频播放进度位置,单位为s。 |
### requestFullscreen
......@@ -119,7 +119,7 @@ requestFullscreen(value: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ----- | ------ | ---- | ------- |
| ----- | ------- | ---- | --------------------- |
| value | boolean | 是 | 是否全屏播放。<br/>默认值:false |
### exitFullscreen
......@@ -137,7 +137,7 @@ setCurrentTime(value: number, seekMode: SeekMode)
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | ---- | ------------------ |
| -------- | -------- | ---- | -------------- |
| value | number | 是 | 视频播放进度位置,单位为s。 |
| seekMode | SeekMode | 是 | 跳转模式。 |
......
......@@ -58,6 +58,6 @@ JS服务卡片(entry/src/main/js/Widget)的典型开发目录结构如下:
## 配置文件
FA卡片需要在应用配置文件config.json中进行配置。详细的配置内容请参考[FA卡片配置文件说明](../../ability/fa-formability.md#配置卡片配置文件)
FA卡片需要在应用配置文件config.json中进行配置。详细的配置内容请参考[FA卡片配置文件说明](../../application-models/widget-development-fa.md#配置卡片配置文件)
Stage卡片需要在应用配置文件module.json5中的extensionAbilities标签下,配置ExtensionAbility相关信息。详细的配置内容请参考[Stage卡片配置文件说明](../../ability/stage-formextension.md#配置卡片配置文件)
\ No newline at end of file
Stage卡片需要在应用配置文件module.json5中的extensionAbilities标签下,配置ExtensionAbility相关信息。详细的配置内容请参考[Stage卡片配置文件说明](../../application-models/widget-development-stage.md#配置卡片配置文件)
\ No newline at end of file
......@@ -63,7 +63,7 @@ CSS是描述HML页面结构的样式语言。所有组件均存在系统默认
css选择器用于选择需要添加样式的元素,支持的选择器如下表所示:
| 选择器 | 样例 | 样例描述 |
| -------- | -------- | -------- |
| ------ | ---------- | ------------------------- |
| .class | .container | 用于选择class="container"的组件。 |
| \#id | \#titleId | 用于选择id="titleId"的组件。 |
......
......@@ -37,24 +37,24 @@
## UI与Ability框架的关系
Ability也是OpenHarmony应用的重要组成部分,[Ability框架](../ability/ability-brief.md)包括FA模型与Stage模型两种模型。下表给出了Ability框架的两种模型分别与方舟开发框架的两种开发范式的关系。
OpenHarmony提供了FA模型与Stage模型两种[应用模型](../application-models/application-model-description.md)。下表给出了两种模型分别与方舟开发框架的两种开发范式的关系。
**FA模型:**
| 类型 | UI开发范式 | 说明 |
| -------- | --------------------------- | --------------------------- |
| 应用 | 类web开发范式 | UI开发语言:使用hml/css/js <br>业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability)<br>业务逻辑语言:js/ts |
| | 声明式开发范式 | UI开发语言:ArkTS <br>业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability) <br>业务逻辑语言:js/ts |
| 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action) <br>业务入口:form.ts <br>卡片业务逻辑语言:js/ts |
| | 声明式开发范式 | 当前不支持 |
| 类型 | UI开发范式 | 说明 |
| ---- | -------- | ---------------------------------------- |
| 应用 | 类web开发范式 | UI开发语言:使用hml/css/js <br>业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability)<br>业务逻辑语言:js/ts |
| | 声明式开发范式 | UI开发语言:ArkTS <br>业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability) <br>业务逻辑语言:js/ts |
| 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action) <br>业务入口:form.ts <br>卡片业务逻辑语言:js/ts |
| | 声明式开发范式 | 当前不支持 |
**Stage模型:**
| 类型 | UI开发范式 | 说明 |
| -------- | --------------------------- | --------------------------- |
| 应用 | 类web开发范式 | 当前不支持 |
| | 声明式开发范式 | UI开发语言:ArkTS <br>业务入口:应用模型基于ohos.application.Ability/ExtensionAbility等派生 <br>业务逻辑语言:ts |
| 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action) <br>业务入口:从FormExtensionAbility派生 <br>业务逻辑语言:ts |
| | 声明式开发范式 | 当前不支持 |
| 类型 | UI开发范式 | 说明 |
| ---- | -------- | ---------------------------------------- |
| 应用 | 类web开发范式 | 当前不支持 |
| | 声明式开发范式 | UI开发语言:ArkTS <br>业务入口:应用模型基于ohos.application.Ability/ExtensionAbility等派生 <br>业务逻辑语言:ts |
| 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action) <br>业务入口:从FormExtensionAbility派生 <br>业务逻辑语言:ts |
| | 声明式开发范式 | 当前不支持 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册