From 0342a97eb7c964e5c0319c8b87a591e55f547bad Mon Sep 17 00:00:00 2001 From: Zjl <502242791@qq.com> Date: Sun, 28 Apr 2019 17:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8Fbug=20=20e.touches[0?= =?UTF-8?q?]=20=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e.touches[0] 获取不到 在其他项 --- dist/wxcharts.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/wxcharts.js b/dist/wxcharts.js index e2fb996..5464a4c 100644 --- a/dist/wxcharts.js +++ b/dist/wxcharts.js @@ -1960,7 +1960,7 @@ Charts.prototype.addEventListener = function (type, listener) { }; Charts.prototype.getCurrentDataIndex = function (e) { - var touches = e.touches && e.touches.length ? e.touches : e.changedTouches; + var touches = e.touches && e.touches.length && e.touches[e.touches.length-1].x? e.touches : e.changedTouches; if (touches && touches.length) { var _touches$ = touches[0], x = _touches$.x, @@ -2008,14 +2008,20 @@ Charts.prototype.showToolTip = function (e) { Charts.prototype.scrollStart = function (e) { if (e.touches[0] && this.opts.enableScroll === true) { - this.scrollOption.startTouchX = e.touches[0].x; + this.scrollOption.startTouchX = e.touches[e.touches.length - 1].x; } }; Charts.prototype.scroll = function (e) { // TODO throtting... if (e.touches[0] && this.opts.enableScroll === true) { - var _distance = e.touches[0].x - this.scrollOption.startTouchX; + let nowitem = {} + e.touches.forEach(el => { + if (el.x) { + nowitem = el + } + }) + var _distance = nowitem.x - this.scrollOption.startTouchX; var currentOffset = this.scrollOption.currentOffset; var validDistance = calValidDistance(currentOffset + _distance, this.chartData, this.config, this.opts);