diff --git a/src/components/interact.js b/src/components/interact.js index 30ed6b7..75acb5d 100644 --- a/src/components/interact.js +++ b/src/components/interact.js @@ -2,6 +2,8 @@ import paper, { Point } from 'paper' import { Cache } from './cache' import { EventListeners } from './eventListeners' +const navigator = window.navigator + export class Interact { #bounds #cache = new Cache(Object.values(Interact.CacheKeys)) @@ -162,6 +164,15 @@ export class Interact { return new Point(event.clientX, event.clientY) } + static vibrate (pattern = 25) { + if (Interact.canVibrate) { + navigator.vibrate(pattern) + } + } + + // WebKit does not support vibration + static canVibrate = typeof navigator.vibrate === 'function' + static CacheKeys = Object.freeze({ Down: 'down', Move: 'move', @@ -176,5 +187,4 @@ export class Interact { static maxZoom = 2 static minZoom = 0.5 - static vibratePattern = 25 } diff --git a/src/components/modifier.js b/src/components/modifier.js index ca47d5e..dbbcd0b 100644 --- a/src/components/modifier.js +++ b/src/components/modifier.js @@ -7,7 +7,6 @@ import { Item } from './item' const modifiersImmutable = document.getElementById('modifiers-immutable') const modifiersMutable = document.getElementById('modifiers-mutable') -const navigator = window.navigator let uniqueId = 0 @@ -148,7 +147,7 @@ export class Modifier extends Stateful { onSelected () { Modifier.deselect() - navigator.vibrate(Interact.vibratePattern) + Interact.vibrate() this.update({ selected: true }) @@ -167,7 +166,7 @@ export class Modifier extends Stateful { } onToggle () { - navigator.vibrate(Interact.vibratePattern) + Interact.vibrate() } remove () { diff --git a/src/styles.css b/src/styles.css index 95c2724..5609c20 100644 --- a/src/styles.css +++ b/src/styles.css @@ -144,6 +144,8 @@ body > header { position: relative; /* Prevent Chrome from trying to open search on tap in mobile. */ user-select: none; + /* For iOS/Safari. */ + -webkit-user-select: none; z-index: 1; } @@ -298,6 +300,8 @@ main { 'GRAD' 0, 'opsz' 24; user-select: none; + /* For iOS/Safari. */ + -webkit-user-select: none; vertical-align: middle; } @@ -308,6 +312,8 @@ main { 'GRAD' 0, 'opsz' 24; user-select: none; + /* For iOS/Safari. */ + -webkit-user-select: none; } .menu { @@ -351,6 +357,8 @@ main { .modifiers { user-select: none; + /* For iOS/Safari. */ + -webkit-user-select: none; } .puzzle-error .flex-left,