mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-30 10:47:22 +08:00
added a try catch to creating a screenshot
This commit is contained in:
parent
38bf4c1eef
commit
2dc13e63c5
1 changed files with 12 additions and 8 deletions
|
|
@ -71,14 +71,18 @@ function copyResultToClipboard() {
|
|||
y: sourceY - 25
|
||||
}).then(function(canvas) {
|
||||
// document.body.appendChild(canvas);
|
||||
canvas.toBlob(function(blob) {
|
||||
let data = [new ClipboardItem({ [blob.type]: blob })];
|
||||
navigator.clipboard.write(data).then(f => {
|
||||
showNotification('Copied to clipboard',1000);
|
||||
}).catch(f => {
|
||||
showNotification('Error saving image to clipboard',2000);
|
||||
})
|
||||
});
|
||||
try{
|
||||
canvas.toBlob(function(blob) {
|
||||
let data = [new ClipboardItem({ [blob.type]: blob })];
|
||||
navigator.clipboard.write(data).then(f => {
|
||||
showNotification('Copied to clipboard',1000);
|
||||
}).catch(f => {
|
||||
showNotification('Error saving image to clipboard',2000);
|
||||
})
|
||||
});
|
||||
}catch(e){
|
||||
showNotification('Error creating image',2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue