forked from seabeepea/seabeepea-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_basic.html
56 lines (51 loc) · 1.61 KB
/
example_basic.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Example: Basic</title>
<style>
.stretch {
width: 100%;
height: 100%;
position: absolute;
left:0; right: 0; top:0; bottom: 0;
}
</style>
</head>
<body>
<p>
This image viewer is part of the normal text flow:
</p>
<div style="width:100%; height: 80vh; position: relative;">
<canvas id="image-layer" class="stretch"></canvas>
<div id="mouse-layer" class="stretch"></div>
</div>
<p>
This is achieved by wrapping the image and mouse layers in a div with relative position
and restricted size.
</p>
<script>
window.resourceBaseUrl = '/';
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.development.js"></script>
<script src="jeri.js"></script>
<script>
const ImageLayer = Jeri.ImageLayer;
const MouseLayer = Jeri.MouseLayer;
const cache = new Jeri.ImageCache();
const imgUrl = "test_image.exr";
cache.get(imgUrl)
.then((image) => {
const imageLayer = new ImageLayer(document.getElementById('image-layer'), image);
const mouseLayer = new MouseLayer(document.getElementById('mouse-layer'), image);
mouseLayer.setEnableMouseEvents(true);
mouseLayer.onTransformationChange(function (transformation) {
imageLayer.setTransformation(transformation);
});
})
.catch((error) => console.error(error));
</script>
</body>
</html>