UNPKG

@opensig/opendesign

Version:

<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>

71 lines (70 loc) 2.41 kB
"use strict"; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); const dom = require("../../_utils/dom.js"); const is = require("../../_utils/is.js"); const pointer = require("../../_utils/pointer.js"); class Effect { constructor(slideElList, slideContainer, options) { __publicField(this, "total"); __publicField(this, "currentIndex"); __publicField(this, "activeClass"); __publicField(this, "onTouchstart"); __publicField(this, "onTouchend"); __publicField(this, "onBeforeChange"); __publicField(this, "onChanged"); __publicField(this, "isTouchStart"); // 是否开始touch事件 __publicField(this, "containerEl"); this.total = slideElList.length; this.containerEl = slideContainer; this.activeClass = options == null ? void 0 : options.activeClass; this.currentIndex = -1; this.isTouchStart = false; this.onTouchstart = options == null ? void 0 : options.onTouchstart; this.onTouchend = options == null ? void 0 : options.onTouchend; this.onBeforeChange = options == null ? void 0 : options.onBeforeChange; this.onChanged = options == null ? void 0 : options.onChanged; this.handleTouch(); } fixIndex(idx) { const i = idx % this.total; return i >= 0 ? i : i + this.total; } handleTouch() { if (!dom.supportTouch()) { return; } new pointer.OPointer(this.containerEl, { onStart: () => { this.isTouchStart = true; this.handleTouchStart(); if (is.isFunction(this.onTouchstart)) { this.onTouchstart(); } }, onMove: (pos, e) => { if (!this.isTouchStart) { return; } this.handleTouchMove(pos, e); }, onEnd: (pos, e) => { if (!this.isTouchStart) { return; } this.isTouchStart = false; const toIdx = this.handleTouchEnd(pos, e); if (typeof toIdx === "number") { const to = this.fixIndex(toIdx); this.active(to, true, true); } if (is.isFunction(this.onTouchend)) { this.onTouchend(); } } }); } } module.exports = Effect;