From f3697d97838e913f67fc7ab1e9f9c300f061d0f6 Mon Sep 17 00:00:00 2001 From: Andrew McGrath Date: Fri, 18 Jun 2021 14:59:15 -0400 Subject: [PATCH] Check if TouchEvent is defined first (#32) When clicking on an image in the carousel with a mouse, a ReferenceError is thrown because TouchEvent is undefined. --- src/actions/swipeable/swipeable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/swipeable/swipeable.js b/src/actions/swipeable/swipeable.js index e5195c9..1f70f2e 100644 --- a/src/actions/swipeable/swipeable.js +++ b/src/actions/swipeable/swipeable.js @@ -10,7 +10,7 @@ import { import { createDispatcher } from '../../utils/event' function getCoords(event) { - if (event instanceof TouchEvent) { + if ('TouchEvent' in window && event instanceof TouchEvent) { const touch = event.touches[0] return { x: touch ? touch.clientX : 0,