-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
86 lines (73 loc) · 2.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { store, persistor } from './store';
import './index.scss';
import ConnectedSEO from './containers/ConnectedSEO';
import { AppRoutes } from './AppRoutes';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ConnectedSEO />
<AppRoutes />
</PersistGate>
</Provider>
</React.StrictMode>,
document.getElementById('root')
);
// https://stackoverflow.com/questions/19909533/disable-rubber-band-in-ios-full-screen-web-app?noredirect=1&lq=1
document.body.addEventListener(
'touchmove',
function (event) {
var isTouchMoveAllowed = false;
var p = event.target;
while (p != null) {
if (p?.getAttribute('data-can-scroll')) {
isTouchMoveAllowed = p.getAttribute('data-can-scroll');
break;
}
p = p.parentNode;
}
if (!isTouchMoveAllowed) {
event.preventDefault();
}
},
{
passive: false,
useCapture: false,
}
);
// https://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript#4819886
function is_touch_device() {
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
var mq = function (query) {
return window.matchMedia(query).matches;
};
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
return true;
}
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
return mq(query);
}
function ready(fn) {
if (
document.attachEvent
? document.readyState === 'complete'
: document.readyState !== 'loading'
) {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(() => {
if (!is_touch_device()) {
document.body.classList.add('no-touch');
}
});
registerServiceWorker();