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.
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
import { createDispatcher } from '../../utils/event'
|
import { createDispatcher } from '../../utils/event'
|
||||||
|
|
||||||
function getCoords(event) {
|
function getCoords(event) {
|
||||||
if (event instanceof TouchEvent) {
|
if ('TouchEvent' in window && event instanceof TouchEvent) {
|
||||||
const touch = event.touches[0]
|
const touch = event.touches[0]
|
||||||
return {
|
return {
|
||||||
x: touch ? touch.clientX : 0,
|
x: touch ? touch.clientX : 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user