-
Notifications
You must be signed in to change notification settings - Fork 388
/
Copy pathlayers.html
51 lines (46 loc) · 1.82 KB
/
layers.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
<!DOCTYPE html>
<html>
<head>
<script src="../dist/svg-pan-zoom.js"></script>
</head>
<body>
<h1>Demo for svg-pan-zoom: Zooming just one SVG layer</h1>
<div id="container" style="width: 300px; height: 500px; border:1px solid black; ">
<svg id="svg-1" xmlns="http://www.w3.org/2000/svg" style="display: inline; width: inherit; min-width: inherit; max-width: inherit; height: inherit; min-height: inherit; max-height: inherit;" version="1.1">
<defs>
<linearGradient id="linear-gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:rgb(56,121,217);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(138,192,7);stop-opacity:1" />
</linearGradient>
</defs>
<g stroke="#000">
<rect x="0" y="400" width="100" height="100" fill="yellow"/>
</g>
<g fill="none" class="svg-pan-zoom_viewport">
<g stroke="#000" fill="#FFF">
<rect x="5" y="5" width="240" height="240" fill="url(#linear-gradient)"/>
<path d="M 5 5 L 245 245 Z"/>
</g>
</g>
<g stroke="#000">
<rect x="0" y="0" width="100" height="100" fill="pink"/>
</g>
</svg>
</div>
<script>
// Don't use window.onLoad like this in production, because it can only listen to one function.
window.onload = function() {
// Expose to window namespase for testing purposes
window.panZoomInstance = svgPanZoom('#svg-1', {
viewportSelector: '.svg-pan-zoom_viewport',
zoomEnabled: true,
controlIconsEnabled: true,
fit: true,
center: true,
minZoom: 0.1,
eventsListenerElement: document.querySelector('#svg-1 .svg-pan-zoom_viewport')
});
};
</script>
</body>
</html>