1 | import { ComponentType } from 'react'
|
2 | import { StandardProps, CommonEventFunction, CanvasTouchEventFunction, CanvasTouchEvent } from './common'
|
3 |
|
4 | interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
|
5 | /** 指定 canvas 类型,支持 2d 和 webgl
|
6 | * @supported weapp
|
7 | */
|
8 | type?: string
|
9 |
|
10 | /** canvas 组件的唯一标识符,若指定了 type 则无需再指定该属性
|
11 | * @supported weapp
|
12 | */
|
13 | canvasId?: string
|
14 |
|
15 | /** 当在 canvas 中移动时且有绑定手势事件时,禁止屏幕滚动以及下拉刷新
|
16 | * @default false
|
17 | * @supported weapp
|
18 | */
|
19 | disableScroll?: boolean
|
20 |
|
21 | /** 手指触摸动作开始
|
22 | * @supported weapp
|
23 | */
|
24 | onTouchStart?: CanvasTouchEventFunction
|
25 |
|
26 | /** 手指触摸后移动
|
27 | * @supported weapp
|
28 | */
|
29 | onTouchMove?: CanvasTouchEventFunction
|
30 |
|
31 | /** 手指触摸动作结束
|
32 | * @supported weapp
|
33 | */
|
34 | onTouchEnd?: CanvasTouchEventFunction
|
35 |
|
36 | /** 手指触摸动作被打断,如来电提醒,弹窗
|
37 | * @supported weapp
|
38 | */
|
39 | onTouchCancel?: CanvasTouchEventFunction
|
40 |
|
41 | /** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动
|
42 | * @supported weapp
|
43 | */
|
44 | onLongTap?: CommonEventFunction
|
45 |
|
46 | /** 当发生错误时触发 error 事件,detail = {errMsg: 'something wrong'}
|
47 | * @supported weapp
|
48 | */
|
49 | onError?: CommonEventFunction<CanvasProps.onErrorEventDetail>
|
50 |
|
51 | /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
|
52 | * @supported h5
|
53 | */
|
54 | nativeProps?: Record<string, unknown>
|
55 | }
|
56 |
|
57 | declare namespace CanvasProps {
|
58 | interface onErrorEventDetail {
|
59 | errMsg: string
|
60 | }
|
61 | }
|
62 |
|
63 | /** 画布
|
64 | *
|
65 | * `<Canvas />` 组件的 RN 版本尚未实现。
|
66 | * @classification canvas
|
67 | * @supported weapp, tt
|
68 | * @example_react
|
69 | * ```tsx
|
70 | * class App extends Components {
|
71 | * render () {
|
72 | * // 如果是支付宝小程序,则要加上 id 属性,值和canvasId一致
|
73 | * return (
|
74 | * <Canvas style='width: 300px; height: 200px;' canvasId='canvas' />
|
75 | * )
|
76 | * }
|
77 | * }
|
78 | * ```
|
79 | * @example_vue
|
80 | * ```html
|
81 | * <template>
|
82 | * <!-- 如果是支付宝小程序,则要加上 id 属性,值和canvasId一致 -->
|
83 | * <canvas style="width: 300px; height: 200px;" canvas-id="canvas" />
|
84 | * </template>
|
85 | * ```
|
86 | * @see https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html
|
87 | */
|
88 | declare const Canvas: ComponentType<CanvasProps>
|
89 |
|
90 | export { Canvas, CanvasProps }
|