Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序bug 真机上只能移动一次,就卡死不能拖动 #360

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions dist/wxcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down