-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo.html
132 lines (113 loc) · 4.82 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<title>OpenSeadragon HTML Overlay Demo</title>
<script src="https://cdn.jsdelivr.net/npm/openseadragon/build/openseadragon/openseadragon.min.js"></script>
<script src="openseadragon-html-overlay.js"></script>
<style type="text/css">
html,
body {
width: 100%;
height: 100%;
margin: 0;
float: left;
}
.openseadragon1,
.openseadragon2 {
width: calc(50% - 10px);
height: 100%;
margin: 5px;
float: left;
}
.text-overlay,
.text-overlay2 {
position: absolute;
left: 200px;
top: 65px;
width: 420px;
font-size: 25px;
font-family: sans-serif;
color: white;
text-shadow: 3px 3px 2px rgba(0, 0, 0, 0.5);
}
.text-overlay a,
.text-overlay2 a {
color: #DDF;
}
.image-overlay,
.image-overlay2 {
position: absolute;
left: 650px;
top: 65px;
width: 140px;
height: 140px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="contentDiv" class="openseadragon1"></div>
<div id="contentDiv2" class="openseadragon2"></div>
<div class="text-overlay">
<h1>Hello!</h1>
<p>This overlay is using the default scale of 1, but the image width is set to 1000 so the CSS works nicely.</p>
<p>Lorem ipsum <a href="https://openseadragon.github.io" target="_blank">dolor sit amet</a>, consectetur adipiscing elit. Mauris faucibus nec ex et feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nulla ut dignissim nisl.</p>
</div>
<img class="image-overlay" src="openseadragonlogo-transparent.png">
<div class="text-overlay2">
<h1>Hello!</h1>
<p>This overlay is using scale of 1000 and the default image width of 1, which works the same as the other overlay.</p>
<p>Lorem ipsum <a href="https://openseadragon.github.io" target="_blank">dolor sit amet</a>, consectetur adipiscing elit. Mauris faucibus nec ex et feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nulla ut dignissim nisl.</p>
</div>
<img class="image-overlay2" src="openseadragonlogo-transparent.png">
<script>
// ----------
function init() {
var tileSource = {
Image: {
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
Url: "http://openseadragon.github.io/example-images/highsmith/highsmith_files/",
Format: "jpg",
Overlap: "2",
TileSize: "256",
Size: {
Width: "7026",
Height: "9221"
}
}
};
var viewer = OpenSeadragon({
id: "contentDiv",
prefixUrl: "https://cdn.jsdelivr.net/npm/openseadragon/build/openseadragon/images/",
tileSources: [{
tileSource: tileSource,
width: 1000
}]
});
var overlay = viewer.htmlOverlay();
overlay.element().appendChild(document.querySelector('.text-overlay'));
var imageOverlay = document.querySelector('.image-overlay');
overlay.element().appendChild(imageOverlay);
overlay.onClick(imageOverlay, function() {
alert('Hello!');
});
var viewer2 = OpenSeadragon({
id: "contentDiv2",
prefixUrl: "https://cdn.jsdelivr.net/npm/openseadragon/build/openseadragon/images/",
tileSources: [{
tileSource: tileSource
}]
});
var overlay2 = viewer2.htmlOverlay({scale: 1000});
overlay2.element().appendChild(document.querySelector('.text-overlay2'));
var imageOverlay2 = document.querySelector('.image-overlay2');
overlay2.element().appendChild(imageOverlay2);
overlay2.onClick(imageOverlay2, function() {
alert('Hello! This image has different dimensions');
});
}
// ----------
init();
</script>
</body>
</html>