{"id":2097,"date":"2019-04-13T07:52:33","date_gmt":"2019-04-13T07:52:33","guid":{"rendered":"https:\/\/azoora.com\/blog\/?p=2097"},"modified":"2019-07-12T23:59:53","modified_gmt":"2019-07-12T23:59:53","slug":"panzoom-pan-zoom-image-using-js-css3-transforms","status":"publish","type":"post","link":"https:\/\/azoora.com\/blog\/code\/panzoom-pan-zoom-image-using-js-css3-transforms\/","title":{"rendered":"Panzoom: Pan &#038; Zoom Image Using JS &#038; CSS3 Transforms"},"content":{"rendered":"\n<h3>Description:<\/h3>\n\n\n\n<p>Panzoom is a lightweight JavaScript library to pan and zoom images inside a container using drag and mouse wheel events.<\/p>\n\n\n\n<p>Not only images, the library also works with Canvas and SVG elements.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3>How to use it:<\/h3>\n\n\n\n<p>Download and import the minified version of the&nbsp;Panzoom library into the html&nbsp;file.<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td><code>&lt;script<\/code>&nbsp;<code>src=\"\/path\/to\/panzoom.min.js\"&gt;&lt;\/script&gt;<\/code><br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p> Insert images to the webpage. <\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td><code>&lt;img<\/code>&nbsp;<code>class=\"panzoom\"<\/code>&nbsp;<code>src=\"1.jpg\"&gt;<\/code><br><code>&lt;canvas<\/code>&nbsp;<code>class=\"panzoom\"&gt;<\/code><br><code>...<\/code><br><code>&lt;\/canvas&gt;<\/code><br><code>&lt;img<\/code>&nbsp;<code>class=\"panzoom\"<\/code>&nbsp;<code>src=\"1.svg\"<\/code>&nbsp;<code>type=\"image\/svg+xml\"&gt;<\/code><br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Apply the PanZoom functionality to the images.<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td> PanZoom(&#8220;.panzoom&#8221;); <br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Customize the PanZoom functionality with the following options.<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td><code>PanZoom(\".panzoom\", {<\/code><br><br><code>\/\/ min\/max scale<\/code><br><code>minScale : 0.1,<\/code><br><code>maxScale : 5,<\/code><br><br><code>\/\/ increment step<\/code><br><code>increment&nbsp; : 0.05,<\/code><br> <br><code>\/\/ whether to zoom linearly when using increment<\/code><br><code>liner&nbsp; :&nbsp;false<\/code><br><br><code>});<\/code><br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>Demo<\/strong>: <a href=\"https:\/\/cdn.rawgit.com\/SpencerWie\/Panzoom\/b070fa28\/demo\/CanvasExample\/index.html\">Link<\/a><\/p><p><strong>Download<\/strong>: <a href=\"https:\/\/github.com\/SpencerWie\/Panzoom\/archive\/master.zip\">Github<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Description: Panzoom is a lightweight JavaScript library to pan and zoom images inside a container using drag and mouse wheel events. Not only images, the library also works with Canvas and SVG elements.<\/p>\n","protected":false},"author":2,"featured_media":2099,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,12],"tags":[25,87],"jetpack_featured_media_url":"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2019\/03\/Pan-Zoom-Image-Using-JavaScript-And-CSS3-Transforms-Panzoom-min.png","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p7FQPL-xP","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/2097"}],"collection":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/comments?post=2097"}],"version-history":[{"count":2,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/2097\/revisions"}],"predecessor-version":[{"id":2173,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/2097\/revisions\/2173"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media\/2099"}],"wp:attachment":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media?parent=2097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/categories?post=2097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/tags?post=2097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}