This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.html
42 lines (39 loc) · 1.77 KB
/
demo.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="css/photoeditor.css">
<script type="text/javascript" src="js/photoeditor.js"></script>
<title>Edit Image Demo</title>
</head>
<body>
<img class="image-view" id="image-view" src="https://znews-photo.zadn.vn/w660/Uploaded/mdf_drkydd/2019_08_10/0.jpg">
</body>
<script>
document.getElementById('image-view').addEventListener("click", function() {
var $photo_editor_box = document.createElement("div");
$photo_editor_box.style.backgroundColor = "rgba(0,0,0, 0.5)";
$photo_editor_box.style.width = "100vw";
$photo_editor_box.style.height = "100vh";
$photo_editor_box.style.top = 0;
$photo_editor_box.style.left = 0;
$photo_editor_box.style.zIndex = "10000";
$photo_editor_box.style.textAlign = "center";
$photo_editor_box.style.position = "fixed";
var $container = document.createElement("div");
$container.style.width = window.innerWidth-50 + "px";
$container.style.height = window.innerHeight + "px";
$container.style.top = "50%";
$container.style.transform = "translateY(-50%)";
$container.style.display = "inline";
$container.setAttribute('class', 'pe_container1');
document.getElementsByTagName("BODY")[0].appendChild($photo_editor_box);
$photo_editor_box.appendChild($container);
var img = document.getElementsByClassName('image-view')[0];
var photoeditor_box = document.getElementsByClassName('pe_container1')[0];
photoEditor.init(img, photoeditor_box);
});
</script>
</html>