-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimg.js
31 lines (27 loc) · 1.02 KB
/
img.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
let photoDiv = document.querySelector("#photo");
let photoUploadInput = document.querySelector("#photo-upload");
let downloadDiv = document.querySelector("#download");
photoDiv.addEventListener("click", function () {
photoUploadInput.click();
});
photoUploadInput.addEventListener("change", function (event) {
console.log(event);
let fileObj = event.target.files[0];
console.log(fileObj);
let filePath = URL.createObjectURL(fileObj, { type: "image/jpg" });
let img = document.createElement("img");
img.setAttribute("src", filePath);
img.classList.add("sticky-image");
addSticky(img);
});
downloadDiv.addEventListener("click" , function(){
html2canvas(document.getElementsByTagName("body")[0]).then(function (canvas) {
var anchorTag = document.createElement("a");
document.body.appendChild(anchorTag);
//document.getElementById("previewImg").appendChild(canvas);
anchorTag.download = "canvas.jpg";
anchorTag.href = canvas.toDataURL();
anchorTag.target = '_blank';
anchorTag.click();
});
})