touch.js 1.3 KB

1
  1. "use strict"; function _classCallCheck(e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") } Object.defineProperty(exports, "__esModule", { value: !0 }); var _createClass = function () { function e(e, t) { for (var a = 0; a < t.length; a++) { var n = t[a]; n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n) } } return function (t, a, n) { return a && e(t.prototype, a), n && e(t, n), t } }(), startX, startY, touch = function () { function e() { _classCallCheck(this, e) } return _createClass(e, [{ key: "_touchstart", value: function (e, t) { return t.forEach(function (e, t) { e.isTouchMove && (e.isTouchMove = !1) }), startX = e.changedTouches[0].clientX, startY = e.changedTouches[0].clientY, t } }, { key: "_touchmove", value: function (e, t, a) { var n = e.currentTarget.dataset.id, r = e.changedTouches[0].clientX, c = e.changedTouches[0].clientY, o = this._angle({ X: startX, Y: startY }, { X: r, Y: c }); return t.forEach(function (e, t) { e.isTouchMove = !1, Math.abs(o) > 30 || e[a] == n && (e.isTouchMove = !(r > startX)) }), t } }, { key: "_angle", value: function (e, t) { var a = t.X - e.X, n = t.Y - e.Y; return 360 * Math.atan(n / a) / (2 * Math.PI) } }]), e }(); exports.default = touch;