diff --git a/README.md b/README.md index 0ca567d..4d96e8f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -## Install dev server packages +# Pan-Zoom - docker run --rm -w /app -v $PWD:/app -u $(id -u):$(id -u) node npm install +Pan/zoom library for web browsers. Hold and drag an element to pan. Use the mouse wheel to zoom. See `src/app.js` for a usage example. -## Start the dev server +## To view the demo using Docker - docker run --rm --init -it -w /app -v $PWD:/app -p 8080:8080 node node dev-server.js +1. Install the development server packages. -Visit `localhost:8080` to view. + docker run --rm -w /app -v $PWD:/app -u $(id -u):$(id -u) node npm install + +2. Start the server. + + docker run --rm --init -it -w /app -v $PWD:/app -p 8080:8080 node node dev-server.js + +3. Visit `localhost:8080` to view. diff --git a/package.json b/package.json index fb86df3..ccfb11c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,12 @@ { - "name": "svg-pan-zoom", + "name": "pan-zoom", + "version": "0.1.0", + "browser": "index.js", "devDependencies": { "esbuild": "^0.20.2", "esbuild-server": "^0.3.0" - } + }, + "files": [ + "./src/modules" + ] } diff --git a/public/assets/css/style.css b/public/assets/css/style.css new file mode 100644 index 0000000..db47790 --- /dev/null +++ b/public/assets/css/style.css @@ -0,0 +1,40 @@ +body { + text-align: center; + max-width: 100vw; +} + +.container { + padding: 0; + max-width: 586.033px; + max-height: 586.033px; + margin: 0 auto; + overflow: hidden; + border: 1px solid steelblue; + background-color: gray; +} + +img, object { + touch-action: none; +} + +img { + max-width: 100%; + border: 1px solid silver; + transform: scale(0.9); +} + +.container object, .container.switch img { + display: block; +} + +.container img, .container.switch object { + display: none; +} + +button .button-text.raster, button.switch .button-text.svg { + display: none; +} + +button.switch .button-text.raster { + display: inline; +} diff --git a/public/assets/images/41156165560-4438592e93-o.webp b/public/assets/images/41156165560-4438592e93-o.webp new file mode 100644 index 0000000..2ad3fa4 Binary files /dev/null and b/public/assets/images/41156165560-4438592e93-o.webp differ diff --git a/public/assets/images/image.svg b/public/assets/images/image.svg new file mode 100644 index 0000000..29f9306 --- /dev/null +++ b/public/assets/images/image.svg @@ -0,0 +1,108 @@ + + + diff --git a/public/image.svg b/public/image.svg deleted file mode 100644 index 5a5c3d9..0000000 --- a/public/image.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - diff --git a/public/index.html b/public/index.html index 8040421..35a3030 100644 --- a/public/index.html +++ b/public/index.html @@ -3,31 +3,28 @@
-Click and drag on the image to pan. Use the mouse wheel to zoom in and out.
- ++ +
+ +