Use CSS transformations instead of manipulating the viewBox
This commit is contained in:
@@ -3,31 +3,28 @@
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>SVG Pan & Zoom Example</title>
|
||||
<style>
|
||||
body {
|
||||
text-align: center;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
object {
|
||||
max-height: 400px;
|
||||
max-width: 100%;
|
||||
background-color: lightsteelblue;
|
||||
border: 1px solid steelblue;
|
||||
touch-action: none;
|
||||
}
|
||||
</style>
|
||||
<title>JavaScript/CSS Pan & Zoom Demo</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Pan & Zoom an SVG Image with JavaScript</h1>
|
||||
<h1>Pan & Zoom an Element with CSS/JavaScript</h1>
|
||||
|
||||
<p>
|
||||
Click and drag on the image to pan. Use the mouse wheel
|
||||
to zoom in and out.
|
||||
</p>
|
||||
|
||||
<object type="image/svg+xml" data="image.svg"></object>
|
||||
<p>
|
||||
<button>
|
||||
<span class="button-text svg">Raster image</span>
|
||||
<span class="button-text raster">SVG image</span>
|
||||
</button>
|
||||
</p>
|
||||
|
||||
<div class="container">
|
||||
<object type="image/svg+xml" data="assets/images/image.svg"></object>
|
||||
<img src="assets/images/41156165560-4438592e93-o.webp"/>
|
||||
</div>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user