diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window.md index 0dfe3e88c996fa0f2d250a624d7487df118dbc49..55480e030f86b7b82aebe055613239e001599b7a 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window.md @@ -621,6 +621,20 @@ type WindowAnimationCurveParam = Array<number> | rectType | [RectType](#recttype19) | 否 | 是 | 窗口矩形区域坐标系类型。 | | windowRect | [Rect](#rect7) | 否 | 是 | 相对于屏幕或父窗坐标系的窗口矩形区域信息。| +## KeyFramePolicy20+ + +关键帧策略配置。 + +**系统能力:** SystemCapability.Window.SessionManager + +| 名称 | 类型 | 只读 | 可写 | 说明 | +| ------ | ---- | ----- | ---- | ----------------------- | +| enable | boolean | 否 | 是 | 是否使用关键帧。 | +| interval | number | 否 | 是 | 设置关键帧布局切换拖拽时间间隔,单位为毫秒,默认值为1000。取值范围为正整数,浮点数向下取整。与distance判断为或的关系。 | +| distance | number | 否 | 是 | 设置关键帧布局切换拖拽距离间隔,单位为px,默认值为1000。取值范围为0或正整数,浮点数向下取整。设置为0时,表示忽略拖拽距离因素。与interval判断为或的关系。 | +| animationDuration | number | 否 | 是 | 设置关键帧布局切换动效时间长,单位为毫秒,默认值为100。取值范围为0或正整数,浮点数向下取整。 | +| animationDelay | number | 否 | 是 | 设置关键帧布局切换动效延迟,单位为毫秒,默认值为100。取值范围为0或正整数,浮点数向下取整。 | + ## GlobalWindowMode20+ 窗口模式。 @@ -3092,6 +3106,75 @@ try { } ``` +### setDragKeyFramePolicy20+ + +setDragKeyFramePolicy(keyFramePolicy: KeyFramePolicy): Promise<KeyFramePolicy> + +设置窗口拖拽时的关键帧策略。仅支持PC主窗调用。 + +**系统能力:** SystemCapability.Window.SessionManager + +**参数:** + +| 类型 | 说明 | +| ------------------- | --------------------------------------------- | +| [KeyFramePolicy](#keyframepolicy20) | 执行的关键帧策略。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<KeyFramePolicy> | 返回生效的关键帧策略结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | --------------------------------------------- | +| 801 | Capability not supported. Function setSubWindowZLevel can not work correctly due to limited device capabilities. | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service works abnormally. | +| 1300004 | Unauthorized operation. | +| 1300016 | Parameter error. Possible cause: 1. Invalid parameter range; 2. The parameter format is incorrect.| + +**示例:** + +```ts +// EntryAbility.ets +import { UIAbility } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class EntryAbility extends UIAbility { + // ... + onWindowStageCreate(windowStage: window.WindowStage): void { + console.info('onWindowStageCreate'); + let windowClass: window.Window | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let keyFramePolicy: window.KeyFramePolicy = { + enable: true + } + try { + let promise = windowClass.setDragKeyFramePolicy(keyFramePolicy); + promise.then((ret: window.KeyFramePolicy) => { + console.info(`Succeeded set key frame: ${JSON.stringify(ret)}`); + }).catch((err: BusinessError) => { + console.error(`Failed to set key frame. Cause code: ${err.code}, message: ${err.message}`); + }); + } catch (exception) { + console.error(`Failed to set key frame. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + } +} +``` + ### setWindowSystemBarEnable9+ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>