{"id":17195136,"url":"https://github.com/stephanwagner/dompanzoom","last_synced_at":"2025-03-25T07:40:53.317Z","repository":{"id":46329552,"uuid":"405245096","full_name":"StephanWagner/domPanZoom","owner":"StephanWagner","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-18T20:11:17.000Z","size":12892,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T03:23:05.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephanWagner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-11T00:25:58.000Z","updated_at":"2022-12-15T09:42:40.000Z","dependencies_parsed_at":"2023-01-20T19:02:38.669Z","dependency_job_id":null,"html_url":"https://github.com/StephanWagner/domPanZoom","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanWagner%2FdomPanZoom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanWagner%2FdomPanZoom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanWagner%2FdomPanZoom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanWagner%2FdomPanZoom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephanWagner","download_url":"https://codeload.github.com/StephanWagner/domPanZoom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245422921,"owners_count":20612725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T01:49:34.591Z","updated_at":"2025-03-25T07:40:53.298Z","avatar_url":"https://github.com/StephanWagner.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# domPanZoom\n\nA lightweight library providing mobile friendly panning and zooming to any HTML DOM element.\n\n---\n\n## Install\n\n### ES6\n\n```bash\nnpm install dompanzoom --save\n```\n\n```javascript\nimport domPanZoom from 'dompanzoom';\n```\n\n### CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/dompanzoom@v0.0.5/dist/domPanZoom.min.js\"\u003e\u003c/script\u003e\n```\n\n---\n\n## Usage\n\nYou need two HTML DOM elements.\\\nThe panZoom element within a wrapper element:\n\n```html\n\u003cdiv id=\"my-wrapper\"\u003e\n  \u003cdiv id=\"my-container\"\u003e\n    \u003cp\u003eYou can add any HTML here\u003cp\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\nThen create a new instance of domPanZoom:\n\n```javascript\nnew domPanZoom({\n  wrapperElement: '#my-wrapper',\n  panZoomElement: '#my-container'\n});\n```\n\nThe options `wrapperElement` and `panZoomElement` are required.\\\nYou can use any query selector or the actual DOM element instance.\n\n\u003e It is highly recommended to give the `panZoomElement` an actual width and height via CSS to avoid size calculation errors due to DOM drawing issues.\n\n---\n\n## Options\n\nYou can pass the following options into domPanZoom:\n\n| Option | Default |  |\n| --- | --- | --- |\n| `center` | `true` | Start with a centered position. This option overrides `initalPanX` and `initialPanY` |\n| `bounds` | `cover` | Set this option to `'contain'` or `'cover'` to limit the boundries of the panZoomElement to the wrapperElement. This works similar to the CSS property background-size: contain / cover. Setting this option might effect the option minZoom |\n| `minZoom` | `0.1` | Minimum zoom, `0.5` would be half the original size |\n| `maxZoom` | `10` | Maximum zoom, `2` would be double the original size |\n| `panStep` | `10` | How many percent to pan by default with the panning methods panLeft, panRight, panUp and panDown |\n| `zoomStep` | `50` | How many percent to zoom by default with the methods zoomIn and zoomOut |\n| `zoomWheelSpeed` | `1` | The speed in which to zoom when using the mouse wheel |\n| `initialZoom` | `1` | Initial zoom level |\n| `initialPanX` | `0` | Initial horizontal pan in percent |\n| `initialPanY` | `0` | Initial vertical pan in percent |\n| `transitionSpeed` | `400` | Transition speed in milliseconds, higher values are slower |\n\n### E.g.\n\n```javascript\nnew domPanZoom({\n  wrapperElement: '#my-wrapper',\n  panZoomElement: '#my-container',\n  bounds: false,\n  minZoom: 1\n});\n```\n\n---\n\n## Methods\n\nYou can use the following methods:\n\n| Getters |  |\n| --- | --- |\n| `.getPan()` | Returns an object with X and Y values of current pan position. You can pass `true` to get the actual pixel values, e.g. `.getPan(true)` |\n| `.getPanX()` | Returns the current horizontal position. You can pass `true` to get the actual pixel values, e.g. `.getPanX(true)` |\n| `.getPanY()` | Returns the current vertical position. You can pass `true` to get the actual pixel values, e.g. `.getPanY(true)` |\n| `.getZoom()` | Returns the current zoom level |\n\n| Setters |  |\n| --- | --- |\n| `.panLeft()`\u003cbr\u003e`.panRight()`\u003cbr\u003e`.panUp()`\u003cbr\u003e`.panDown()` | Pan a specific direction. You can pass a number to pan a specific amount (in percent). Pass `true` as first or second argument to pan instantly, e.g. `.panLeft(50)`, `.panRight(true)`, `.panUp(30, true)` |\n| `.panTo(x, y)` | Pan to a specific position. The `x` and `y` values are in percent, so `.panTo(50, 50)` will pan to the center. Pass `true` as third argument to pan instantly, e.g. `.panTo(50, 50, true)`\n| `.center()` | Pan to centered position. Pass `true` to center instantly, e.g. `.center(true)` |\n| `.zoomIn()`\u003cbr\u003e`.zoomOut()` | Zoom in and out. You can pass a number to zoom a specific amount (in percent). Pass `true` as first or second argument to zoom instantly, e.g. `.zoomIn(20)`, `.zoomIn(true)`, `.zoomIn(50, true)` |\n| `.zoomTo(2)` | Zoom to a specific zoom level. Pass `true` as a second argument to zoom instantly, e.g. `.zoomTo(2, true)` |\n\n### E.g.\n\n```javascript\nvar myDomPanZoom = new domPanZoom({\n  wrapperElement: '#my-wrapper',\n  panZoomElement: '#my-container'\n});\n\nmyDomPanZoom.panTo(20, 80);\n```\n\n---\n\n## Events\n\n| Event |  |\n| --- | --- |\n| `onInit` | Triggered once domPanZoom is initialized |\n| `onChange` | Triggered when panning or zooming |\n| `onZoom` | Triggered when zooming |\n| `onPan` | Triggered when panning |\n\n### E.g.\n\n```javascript\nnew domPanZoom({\n  wrapperElement: '#my-wrapper',\n  panZoomElement: '#my-container'\n  onZoom: function (position) {\n    console.log(this.zoom, position);\n  }\n});\n```\n\n---\n\n## Attribution\n\nThis library is heavily inspired by https://github.com/anvaka/panzoom.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanwagner%2Fdompanzoom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanwagner%2Fdompanzoom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanwagner%2Fdompanzoom/lists"}