UNPKG

@tarojs/components

Version:
1 lines 1.33 kB
import{r as registerInstance,c as createEvent,h,g as getElement}from"./index-ab3c86da.js";var indexCss="taro-canvas-core{width:300px;height:150px;display:block;position:relative}";var LONG_TAP_DELAY=500;var Canvas=function(){function t(t){var e=this;registerInstance(this,t);this.onLongTap=createEvent(this,"longtap",7);this.onTouchStart=function(){e.timer=setTimeout((function(){e.onLongTap.emit()}),LONG_TAP_DELAY)};this.onTouchMove=function(){clearTimeout(e.timer)};this.onTouchEnd=function(){clearTimeout(e.timer)};this.canvasId=undefined;this.height=undefined;this.width=undefined;this.nativeProps={}}t.prototype.componentDidRender=function(){var t=this.el.children[0];if(!this.height||!this.width){var e=window.getComputedStyle(t);this.height||(this.height=e.height);this.width||(this.width=e.width)}t.height=parseInt(this.height);t.width=parseInt(this.width)};t.prototype.render=function(){var t=this,e=t.canvasId,i=t.nativeProps;return h("canvas",Object.assign({"canvas-id":e,style:{width:"100%",height:"100%"},onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchCancel:this.onTouchEnd,onTouchEnd:this.onTouchEnd},i))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();Canvas.style=indexCss;export{Canvas as taro_canvas_core};