UNPKG

@tarojs/components

Version:
1 lines 1.72 kB
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-ab3c86da.js";import{c as classnames}from"./index-c3e4004b.js";import{h as handleStencilNodes}from"./helper-8a85bb65.js";import"@tarojs/taro";var indexCss="body,html{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}taro-view-core{display:block}";var View=function(){function t(t){registerInstance(this,t);this.onLongPress=createEvent(this,"longpress",7);this.startTime=0;this.animation=undefined;this.hoverClass=undefined;this.hoverStartTime=50;this.hoverStayTime=400;this.hover=false;this.touch=false}t.prototype.onTouchStart=function(){var t=this;if(this.hoverClass){this.touch=true;setTimeout((function(){if(t.touch){t.hover=true}}),this.hoverStartTime)}this.timeoutEvent=setTimeout((function(){t.onLongPress.emit()}),350);this.startTime=Date.now()};t.prototype.onTouchMove=function(){clearTimeout(this.timeoutEvent)};t.prototype.onTouchEnd=function(){var t=this;var e=Date.now()-this.startTime;if(e<350){clearTimeout(this.timeoutEvent)}if(this.hoverClass){this.touch=false;setTimeout((function(){if(!t.touch){t.hover=false}}),this.hoverStayTime)}};t.prototype.componentDidRender=function(){handleStencilNodes(this.el)};t.prototype.render=function(){var t;var e=classnames((t={},t["".concat(this.hoverClass)]=this.hover,t));var i={};if(!!this.animation){i["animation"]=this.animation;i["data-animation"]=this.animation}return h(Host,Object.assign({class:e},i),h("slot",null))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();View.style=indexCss;export{View as taro_view_core};