Skip to content

Commit caee68b

Browse files
committed
fix for mobile
1 parent 44b14df commit caee68b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

bundle/latex2html5.bundle.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,9 @@ const psgraph = {
14711471
});
14721472
svg.on('touchmove', function (event) {
14731473
event.preventDefault();
1474-
var touchcoords = event.touches ? event.touches[0] : [0, 0];
1474+
var touch = event.touches ? event.touches[0] : null;
1475+
var rect = event.target.getBoundingClientRect();
1476+
var touchcoords = touch ? [touch.clientX - rect.left, touch.clientY - rect.top] : [0, 0];
14751477
userEvent(touchcoords);
14761478
});
14771479
svg.on('mousemove', function (event) {

packages/pstricks/src/lib/psgraph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ const psgraph: any = {
605605
'touchmove',
606606
function (this: any, event: any) {
607607
event.preventDefault();
608-
var touchcoords = event.touches ? event.touches[0] : [0, 0];
608+
var touch = event.touches ? event.touches[0] : null;
609+
var rect = event.target.getBoundingClientRect();
610+
var touchcoords = touch ? [touch.clientX - rect.left, touch.clientY - rect.top] : [0, 0];
609611
userEvent(touchcoords);
610612
}
611613
);

0 commit comments

Comments
 (0)