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