Skip to content

Commit 4e51f3a

Browse files
committed
feat: add warning message
1 parent 116e132 commit 4e51f3a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

script.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
var imgEditor = new ImageEditor('#image-editor-container');
1+
try {
2+
var imgEditor = new ImageEditor('#image-editor-container');
3+
console.log('initialize image editor')
4+
} catch (_) {
5+
const browserWarning = document.createElement('div')
6+
browserWarning.innerHTML = '<p style="line-height: 26px; margin-top: 100px; font-size: 16px; color: #555">Your browser is out of date!<br/>Please update to a modern browser, for example:<a href="https://www.google.com/chrome/" target="_blank">Chrome</a>!</p>';
7+
8+
browserWarning.setAttribute(
9+
'style',
10+
'position: fixed; z-index: 1000; width: 100%; height: 100%; top: 0; left: 0; background-color: #f9f9f9; text-align: center; color: #555;'
11+
)
12+
13+
// check for flex and grid support
14+
let divGrid = document.createElement('div')
15+
divGrid.style['display'] = 'grid'
16+
let supportsGrid = divGrid.style['display'] === 'grid'
17+
18+
let divFlex = document.createElement('div')
19+
divFlex.style['display'] = 'flex'
20+
let supportsFlex = divFlex.style['display'] === 'flex'
21+
22+
if (!supportsGrid || !supportsFlex) {
23+
document.body.appendChild(browserWarning)
24+
}
25+
}

0 commit comments

Comments
 (0)