UNPKG

1.07 kBJavaScriptView Raw
1import { r as registerInstance, c as createEvent, h, g as getElement } from './index-5bd7cbab.js';
2
3const indexCss = "taro-canvas-core{display:block;position:relative;width:300px;height:150px}";
4
5const LONG_TAP_DELAY = 500;
6let Canvas = class {
7 constructor(hostRef) {
8 registerInstance(this, hostRef);
9 this.onLongTap = createEvent(this, "longtap", 7);
10 this.nativeProps = {};
11 this.onTouchStart = () => {
12 this.timer = setTimeout(() => {
13 this.onLongTap.emit();
14 }, LONG_TAP_DELAY);
15 };
16 this.onTouchMove = () => {
17 clearTimeout(this.timer);
18 };
19 this.onTouchEnd = () => {
20 clearTimeout(this.timer);
21 };
22 }
23 render() {
24 const { canvasId, nativeProps } = this;
25 return (h("canvas", Object.assign({ "canvas-id": canvasId, style: {
26 width: '100%',
27 height: '100%'
28 }, onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onTouchEnd: this.onTouchEnd }, nativeProps)));
29 }
30 get el() { return getElement(this); }
31};
32Canvas.style = indexCss;
33
34export { Canvas as taro_canvas_core };