Skip to content

Commit

Permalink
wx app touch
Browse files Browse the repository at this point in the history
  • Loading branch information
fefeding committed Oct 29, 2024
1 parent 0f21368 commit c4c7276
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/jmgraph.core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jmgraph.core.min.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions dist/jmgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -3928,11 +3928,12 @@ var jmUtils = exports.jmUtils = exports["default"] = /*#__PURE__*/function () {
key: "getEventPosition",
value: function getEventPosition(evt, scale) {
evt = evt || event;
var isWXMiniApp = evt.isWXMiniApp;
var isTouch = false;
var touches = evt.changedTouches || evt.targetTouches || evt.touches;
var target = evt.target || evt.srcElement;
if (touches && touches.length) {
evt = touches[0]; //兼容touch事件
evt = touches[0]; //兼容touch事件
if (!evt.target) evt.target = target;
isTouch = true;
}
Expand All @@ -3944,7 +3945,7 @@ var jmUtils = exports.jmUtils = exports["default"] = /*#__PURE__*/function () {
var oy = evt.offsetY;
if (typeof ox === 'undefined' && typeof oy === 'undefined') {
// 小程序下取x,y就是它的相对坐标
if (evt.isWXMiniApp) {
if (isWXMiniApp) {
ox = evt.x;
oy = evt.y;
} else {
Expand Down Expand Up @@ -3972,7 +3973,8 @@ var jmUtils = exports.jmUtils = exports["default"] = /*#__PURE__*/function () {
x: ox,
y: oy,
isTouch: isTouch,
touches: touches
touches: touches,
isWXMiniApp: isWXMiniApp
};
}

Expand Down
2 changes: 1 addition & 1 deletion dist/jmgraph.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"family": "jmgraph",
"name": "jmgraph",
"version": "3.2.10",
"version": "3.2.11",
"description": "一个简单的canvas画图库",
"homepage": "http://graph.jm47.com/",
"keywords": [
Expand Down
9 changes: 5 additions & 4 deletions src/core/jmUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ export default class jmUtils {
*/
static getEventPosition (evt, scale) {
evt = evt || event;

const isWXMiniApp = evt.isWXMiniApp;
let isTouch = false;
let touches = evt.changedTouches || evt.targetTouches || evt.touches;
let target = evt.target || evt.srcElement;
if(touches && touches.length) {
evt = touches[0];//兼容touch事件
evt = touches[0];//兼容touch事件
if(!evt.target) evt.target = target;
isTouch = true;
}
Expand All @@ -335,7 +335,7 @@ export default class jmUtils {
let oy = evt.offsetY;
if(typeof ox === 'undefined' && typeof oy === 'undefined') {
// 小程序下取x,y就是它的相对坐标
if(evt.isWXMiniApp) {
if(isWXMiniApp) {
ox = evt.x;
oy = evt.y;
}
Expand Down Expand Up @@ -365,7 +365,8 @@ export default class jmUtils {
x: ox,
y: oy,
isTouch: isTouch,
touches
touches,
isWXMiniApp
};
}

Expand Down

0 comments on commit c4c7276

Please sign in to comment.