Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sanichkotikov/pinch-zoom-pan

A simple module that add pinch-zoom and pan to your HTML element
https://github.com/sanichkotikov/pinch-zoom-pan

nativejs npm-module npm-package pan pinch zoom

Last synced: about 1 month ago
JSON representation

A simple module that add pinch-zoom and pan to your HTML element

Awesome Lists containing this project

README

        

# pinch-zoom-pan

A simple module that add pinch-zoom and pan to your HTML element.

## Using

```bash
npm i -S pinch-zoom-pan
```

```html








```

```css
.root {
position: relative;
transform: translateZ(0);
overflow: hidden;
}

.point {
position: absolute;
width: 0;
height: 0;
transform: translate(0, 0) scale(1);
transform-origin: center;
will-change: transform;
}

.canvas {
position: absolute;
transform: translate(-50%, -50%);
}
```

```javascript
import { create } from 'pinch-zoom-pan';

// Run module on mount
const canvas = create({
element: document.getElementById('root'),
// optional settings:
minZoom: 0.5,
maxZoom: 2,
captureWheel: true,
});

// Should be called on unmount
canvas.destroy();

// Reset position and zoom to default values
canvas.reset();

// Manually update position and zoom
canvas.update({ z: 1.2 });
canvas.update((prev) => ({ z: prev.z + 0.2 }));
```

## Frameworks & libraries

* [React example](https://github.com/SanichKotikov/react-family-tree-example/tree/master/src/components/PinchZoomPan)
* [Solid example](https://github.com/SanichKotikov/solid-family-tree-example/tree/master/src/components/PinchZoomPan)

## Contributing

Please read [this documentation](https://github.com/SanichKotikov/contributing) before contributing.