项目作者: kundansingh86

项目描述 :
Pan, Pinch and Zoom on Image
高级语言: JavaScript
项目地址: git://github.com/kundansingh86/Image-Pan-Pinch-Zoom.git
创建时间: 2019-12-09T19:03:21Z
项目社区:https://github.com/kundansingh86/Image-Pan-Pinch-Zoom

开源协议:MIT License

下载


Image Pan-Pinch-Zoom

A javascript library to apply pan, pinch and zoom on an image bound a container box.

Getting Started

Html, CSS and JS

  1. <div class="container" id="container">
  2. <img src="Koala.jpg" id="imageZoom" />
  3. </div>
  1. .container {
  2. width: 500px;
  3. height: 400px;
  4. overflow: hidden;
  5. border: solid 1px black;
  6. }

Include Javascript in HTML Page

  1. <script type="text/javascript" src="touchScriptController.js"></script>

Apply touchScriptController to the image and container element

  1. let touchControl = new touchScriptController(
  2. document.getElementById('imageZoom'), // Image Element
  3. document.getElementById('container'), // Parent Container Element
  4. { // Options to preset the scale and translate
  5. scale: 1,
  6. translateX: 0,
  7. translateY: 0
  8. });

For example, refer the index.html file.