Skip to content

Commit 0a1fce2

Browse files
committed
Add check, if touches.length > 0
1 parent eedd66d commit 0a1fce2

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "three.interactive",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "Fast and simple interaction manager for THREE.js",
55
"type": "module",
66
"types": "./build/index.d.ts",

src/index.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ export class InteractionManager {
270270
onTouchMove = (touchEvent: TouchEvent) => {
271271
// event.preventDefault();
272272

273-
this.mapPositionToPoint(
274-
this.mouse,
275-
touchEvent.touches[0].clientX,
276-
touchEvent.touches[0].clientY
277-
);
273+
if (touchEvent.touches.length > 0) {
274+
this.mapPositionToPoint(
275+
this.mouse,
276+
touchEvent.touches[0].clientX,
277+
touchEvent.touches[0].clientY
278+
);
279+
}
278280

279281
const event = new InteractiveEvent(
280282
this.treatTouchEventsAsMouseEvents ? 'mousemove' : 'touchmove',
@@ -331,11 +333,13 @@ export class InteractionManager {
331333
};
332334

333335
onTouchStart = (touchEvent: TouchEvent) => {
334-
this.mapPositionToPoint(
335-
this.mouse,
336-
touchEvent.touches[0].clientX,
337-
touchEvent.touches[0].clientY
338-
);
336+
if (touchEvent.touches.length > 0) {
337+
this.mapPositionToPoint(
338+
this.mouse,
339+
touchEvent.touches[0].clientX,
340+
touchEvent.touches[0].clientY
341+
);
342+
}
339343

340344
this.update();
341345

@@ -368,11 +372,13 @@ export class InteractionManager {
368372
};
369373

370374
onTouchEnd = (touchEvent: TouchEvent) => {
371-
this.mapPositionToPoint(
372-
this.mouse,
373-
touchEvent.touches[0].clientX,
374-
touchEvent.touches[0].clientY
375-
);
375+
if (touchEvent.touches.length > 0) {
376+
this.mapPositionToPoint(
377+
this.mouse,
378+
touchEvent.touches[0].clientX,
379+
touchEvent.touches[0].clientY
380+
);
381+
}
376382

377383
this.update();
378384

0 commit comments

Comments
 (0)