1 | import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-8809c729.js';
|
2 | import { c as classnames } from './index-1d8e8acd.js';
|
3 |
|
4 | const indexCss = "body,html{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}taro-view-core{display:block}";
|
5 |
|
6 | let View = class {
|
7 | constructor(hostRef) {
|
8 | registerInstance(this, hostRef);
|
9 | this.onLongPress = createEvent(this, "longpress", 7);
|
10 | this.hoverStartTime = 50;
|
11 | this.hoverStayTime = 400;
|
12 | this.hover = false;
|
13 | this.touch = false;
|
14 | this.startTime = 0;
|
15 | }
|
16 | onTouchStart() {
|
17 | if (this.hoverClass) {
|
18 | this.touch = true;
|
19 | setTimeout(() => {
|
20 | if (this.touch) {
|
21 | this.hover = true;
|
22 | }
|
23 | }, this.hoverStartTime);
|
24 | }
|
25 | this.timeoutEvent = setTimeout(() => {
|
26 | this.onLongPress.emit();
|
27 | }, 350);
|
28 | this.startTime = Date.now();
|
29 | }
|
30 | onTouchMove() {
|
31 | clearTimeout(this.timeoutEvent);
|
32 | }
|
33 | onTouchEnd() {
|
34 | const spanTime = Date.now() - this.startTime;
|
35 | if (spanTime < 350) {
|
36 | clearTimeout(this.timeoutEvent);
|
37 | }
|
38 | if (this.hoverClass) {
|
39 | this.touch = false;
|
40 | setTimeout(() => {
|
41 | if (!this.touch) {
|
42 | this.hover = false;
|
43 | }
|
44 | }, this.hoverStayTime);
|
45 | }
|
46 | }
|
47 | componentDidRender() {
|
48 | const el = this.el;
|
49 | el.childNodes.forEach(item => {
|
50 |
|
51 | if (item.nodeType === document.COMMENT_NODE && item['s-cn'])
|
52 | item['s-cn'] = false;
|
53 |
|
54 | if (item.nodeType !== document.COMMENT_NODE && item['s-sr'])
|
55 | item['s-sr'] = false;
|
56 | });
|
57 | }
|
58 | render() {
|
59 | const cls = classnames({
|
60 | [`${this.hoverClass}`]: this.hover
|
61 | });
|
62 | let attr = {};
|
63 | if (!!this.animation) {
|
64 | attr['animation'] = this.animation;
|
65 | attr['data-animation'] = this.animation;
|
66 | }
|
67 | return (h(Host, Object.assign({ class: cls }, attr), h("slot", null)));
|
68 | }
|
69 | get el() { return getElement(this); }
|
70 | };
|
71 | View.style = indexCss;
|
72 |
|
73 | export { View as taro_view_core };
|