未验证 提交 295273c3 编写于 作者: O openharmony_ci 提交者: Gitee

!23882 update api jsmd

Merge pull request !23882 from 李欣楠/master
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
## 导入模块 ## 导入模块
```js ```ts
import animator, { AnimatorResult } from '@ohos.animator'; import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
import { BusinessError } from '@ohos.base';
``` ```
## create<sup>9+</sup> ## create<sup>9+</sup>
...@@ -39,10 +40,9 @@ create(options: AnimatorOptions): AnimatorResult ...@@ -39,10 +40,9 @@ create(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```ts
import animator, { AnimatorResult } from '@ohos.animator'; import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = {
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -84,8 +84,10 @@ reset(options: AnimatorOptions): void ...@@ -84,8 +84,10 @@ reset(options: AnimatorOptions): void
**示例:** **示例:**
```js ```ts
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
import { BusinessError } from '@ohos.base';
let options: AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -98,7 +100,9 @@ let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型An ...@@ -98,7 +100,9 @@ let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型An
try { try {
animator.reset(options); animator.reset(options);
} catch(error) { } catch(error) {
console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); let message = (error as BusinessError).message
let code = (error as BusinessError).code
console.error(`Animator reset failed, error code: ${code}, message: ${message}.`);
} }
``` ```
...@@ -112,7 +116,7 @@ play(): void ...@@ -112,7 +116,7 @@ play(): void
**示例:** **示例:**
```js ```ts
animator.play(); animator.play();
``` ```
...@@ -126,7 +130,7 @@ finish(): void ...@@ -126,7 +130,7 @@ finish(): void
**示例:** **示例:**
```js ```ts
animator.finish(); animator.finish();
``` ```
...@@ -140,7 +144,7 @@ pause(): void ...@@ -140,7 +144,7 @@ pause(): void
**示例:** **示例:**
```js ```ts
animator.pause(); animator.pause();
``` ```
...@@ -154,7 +158,7 @@ cancel(): void ...@@ -154,7 +158,7 @@ cancel(): void
**示例:** **示例:**
```js ```ts
animator.cancel(); animator.cancel();
``` ```
...@@ -168,7 +172,7 @@ reverse(): void ...@@ -168,7 +172,7 @@ reverse(): void
**示例:** **示例:**
```js ```ts
animator.reverse(); animator.reverse();
``` ```
...@@ -188,9 +192,10 @@ onframe: (progress: number) => void ...@@ -188,9 +192,10 @@ onframe: (progress: number) => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onframe = function(value) { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onframe = (value)=> {
console.info("onframe callback") console.info("onframe callback")
} }
``` ```
...@@ -205,9 +210,10 @@ onfinish: () => void ...@@ -205,9 +210,10 @@ onfinish: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onfinish = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onfinish = ()=> {
console.info("onfinish callback") console.info("onfinish callback")
} }
``` ```
...@@ -222,9 +228,10 @@ oncancel: () => void ...@@ -222,9 +228,10 @@ oncancel: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.oncancel = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.oncancel = ()=> {
console.info("oncancel callback") console.info("oncancel callback")
} }
``` ```
...@@ -239,9 +246,10 @@ onrepeat: () => void ...@@ -239,9 +246,10 @@ onrepeat: () => void
**示例:** **示例:**
```js ```ts
let animatorResult = animator.create(options) import animator, { AnimatorResult } from '@ohos.animator';
animatorResult.onrepeat = function() { let animatorResult:AnimatorResult|undefined = animator.create(options)
animatorResult.onrepeat = ()=> {
console.info("onrepeat callback") console.info("onrepeat callback")
} }
``` ```
...@@ -277,15 +285,28 @@ animatorResult.onrepeat = function() { ...@@ -277,15 +285,28 @@ animatorResult.onrepeat = function() {
</div> </div>
``` ```
```js ```ts
export default { import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
data: { import { BusinessError } from '@ohos.base';
divWidth: 200, let DataTmp:Record<string,animator> = {
divHeight: 200, 'divWidth': 200,
animator: null 'divHeight': 200,
}, 'animator': animator
}
class Tmp{
data:animator = DataTmp
onInit:Function = ()=>{}
Show:Function = ()=>{}
}
class DateT{
divWidth:number = 0
divHeight:number = 0
animator:AnimatorResult | null = null
}
(Fn:(v:Tmp) => void) => {Fn({
data: DataTmp,
onInit() { onInit() {
let options = { let options:AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -295,10 +316,15 @@ export default { ...@@ -295,10 +316,15 @@ export default {
begin: 200.0, begin: 200.0,
end: 400.0 end: 400.0
}; };
this.animator = animator.create(options); let DataTmp:DateT = {
divWidth: 200,
divHeight: 200,
animator: null
}
DataTmp.animator = animator.create(options);
}, },
Show() { Show() {
let options1 = { let options1:AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -308,19 +334,29 @@ export default { ...@@ -308,19 +334,29 @@ export default {
begin: 0, begin: 0,
end: 400.0, end: 400.0,
}; };
let DataTmp:DateT = {
divWidth: 200,
divHeight: 200,
animator: null
}
try { try {
this.animator.reset(options1); DataTmp.animator = animator.create(options1);
DataTmp.animator.reset(options1);
} catch(error) { } catch(error) {
console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); let message = (error as BusinessError).message
let code = (error as BusinessError).code
console.error(`Animator reset failed, error code: ${code}, message: ${message}.`);
}
let _this = DataTmp;
if(DataTmp.animator){
DataTmp.animator.onframe = (value:number)=> {
_this.divWidth = value;
_this.divHeight = value;
};
DataTmp.animator.play();
} }
let _this = this;
this.animator.onframe = function(value) {
_this.divWidth = value;
_this.divHeight = value;
};
this.animator.play();
} }
} })}
``` ```
![zh-cn_image_00007](figures/zh-cn_image_00007.gif) ![zh-cn_image_00007](figures/zh-cn_image_00007.gif)
...@@ -501,7 +537,7 @@ update(options: AnimatorOptions): void ...@@ -501,7 +537,7 @@ update(options: AnimatorOptions): void
**示例:** **示例:**
```js ```ts
animator.update(options); animator.update(options);
``` ```
...@@ -529,7 +565,8 @@ createAnimator(options: AnimatorOptions): AnimatorResult ...@@ -529,7 +565,8 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```ts
import animator, { AnimatorOptions,AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## 导入模块 ## 导入模块
```js ```ts
import componentSnapshot from "@ohos.arkui.componentSnapshot"; import componentSnapshot from "@ohos.arkui.componentSnapshot";
``` ```
...@@ -42,14 +42,14 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void ...@@ -42,14 +42,14 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void
**示例:** **示例:**
```js ```ts
import componentSnapshot from '@ohos.arkui.componentSnapshot' import componentSnapshot from '@ohos.arkui.componentSnapshot'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry
@Component @Component
struct SnapshotExample { struct SnapshotExample {
@State pixmap: image.PixelMap = undefined @State pixmap: image.PixelMap|undefined = undefined
build() { build() {
Column() { Column() {
...@@ -108,14 +108,14 @@ get(id: string): Promise<image.PixelMap> ...@@ -108,14 +108,14 @@ get(id: string): Promise<image.PixelMap>
**示例:** **示例:**
```js ```ts
import componentSnapshot from '@ohos.arkui.componentSnapshot' import componentSnapshot from '@ohos.arkui.componentSnapshot'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry
@Component @Component
struct SnapshotExample { struct SnapshotExample {
@State pixmap: image.PixelMap = undefined @State pixmap: image.PixelMap|undefined = undefined
build() { build() {
Column() { Column() {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## 导入模块 ## 导入模块
```js ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'; import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor';
``` ```
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## 导入模块 ## 导入模块
```js ```ts
import inspector from '@ohos.arkui.inspector' import inspector from '@ohos.arkui.inspector'
``` ```
...@@ -36,8 +36,8 @@ createComponentObserver(id: string): ComponentObserver ...@@ -36,8 +36,8 @@ createComponentObserver(id: string): ComponentObserver
**示例:** **示例:**
```js ```ts
let listener = inspector.createComponentObserver('COMPONENT_ID'); //监听id为COMPONENT_ID的组件回调事件 let listener:inspector = inspector.createComponentObserver('COMPONENT_ID'); //监听id为COMPONENT_ID的组件回调事件
``` ```
## ComponentObserver ## ComponentObserver
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册