You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "TaR1z (via GitHub)" <gi...@apache.org> on 2024/10/09 03:12:08 UTC
Re: [I] 地图:移动端拖动,拖出边界后,无法再拉回 [echarts]
TaR1z commented on issue #9239:
URL: https://github.com/apache/echarts/issues/9239#issuecomment-2401182660
如果在微信小程序,可以劫持touchMove事件,设置四周边界,但是不完美,强行移动也会导致无法拖回
`javascript
touchMove(e) {
const chart = this.chart;
const needGesture = this.data.needGesture;
const len = e.touches.length;
const width = this.chart.getWidth();
const height = this.chart.getHeight();
const boundary = {
top: 0,
left: 0,
right: width,
bottom: height,
};
if (chart && len > 0) {
const touch = e.touches[0];
const handler = chart.getZr().handler;
const { x, y } = touch;
if (boundary.top > x || boundary.bottom < x || boundary.right < y || boundary.left > y) {
return;
}
if (needGesture && len === TOUCH_POINT_NUM) {
handler.processGesture(wrapTouch(e), 'change');
return;
}
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {},
});
}
},
`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org