UNPKG

@tarojs/components

Version:
86 lines (85 loc) 2.13 kB
// eslint-disable-next-line @typescript-eslint/no-unused-vars import { Component, h, Prop, Element, Event } from '@stencil/core'; const LONG_TAP_DELAY = 500; export class Canvas { constructor() { this.nativeProps = {}; this.onTouchStart = () => { this.timer = setTimeout(() => { this.onLongTap.emit(); }, LONG_TAP_DELAY); }; this.onTouchMove = () => { clearTimeout(this.timer); }; this.onTouchEnd = () => { clearTimeout(this.timer); }; } render() { const { canvasId, nativeProps } = this; return (h("canvas", Object.assign({ "canvas-id": canvasId, style: { width: '100%', height: '100%' }, onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove, onTouchEnd: this.onTouchEnd }, nativeProps))); } static get is() { return "taro-canvas-core"; } static get originalStyleUrls() { return { "$": ["./style/index.scss"] }; } static get styleUrls() { return { "$": ["./style/index.css"] }; } static get properties() { return { "canvasId": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "canvas-id", "reflect": false }, "nativeProps": { "type": "unknown", "mutable": false, "complexType": { "original": "{}", "resolved": "{}", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "defaultValue": "{}" } }; } static get events() { return [{ "method": "onLongTap", "name": "longtap", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } static get elementRef() { return "el"; } }