import { r as registerInstance, c as createEvent, h, H as Host } from './index-c948674f.js';
import { c as classnames } from './index-394db4c1.js';

const coverViewCss = "taro-cover-view-core{display:block}";

const CoverView = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    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;
  }
  onTouchStart() {
    if (this.hoverClass) {
      this.touch = true;
      setTimeout(() => {
        if (this.touch) {
          this.hover = true;
        }
      }, this.hoverStartTime);
    }
    this.timeoutEvent = setTimeout(() => {
      this.onLongPress.emit();
    }, 350);
    this.startTime = Date.now();
  }
  onTouchMove() {
    clearTimeout(this.timeoutEvent);
  }
  onTouchEnd() {
    const spanTime = Date.now() - this.startTime;
    if (spanTime < 350) {
      clearTimeout(this.timeoutEvent);
    }
    if (this.hoverClass) {
      this.touch = false;
      setTimeout(() => {
        if (!this.touch) {
          this.hover = false;
        }
      }, this.hoverStayTime);
    }
  }
  render() {
    const cls = classnames({
      [`${this.hoverClass}`]: this.hover
    });
    let attr = {};
    if (!!this.animation) {
      attr['animation'] = this.animation;
      attr['data-animation'] = this.animation;
    }
    return (h(Host, Object.assign({ class: cls }, attr), h("slot", null)));
  }
};
CoverView.style = coverViewCss;

export { CoverView as taro_cover_view_core };

//# sourceMappingURL=taro-cover-view-core.entry.js.map