Solved

jQuery PanZoom

Posted on 2013-06-23
9
1,312 Views
Last Modified: 2013-06-27
Hi

Does anyone know if you can use buttons for the panzoom panning instead of dragging on this:
https://github.com/timmywil/jquery.panzoom

Thanks
0
Comment
Question by:coolispaul
  • 4
  • 3
  • 2
9 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39277079
yes u can, here the html i used that worked for me with the buttons.
the only file i used is jquery.panzoom.min.js in the same folder of the html.

<!doctype html>
<html>
  <head>
    <title>Panzoom for jQuery</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
      section { text-align: center; margin: 50px 0; }
    </style>
  </head>
  <body>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
	<script src="jquery.panzoom.min.js"></script>
    <section>
      <h1>Panning and zooming with CSS3</h1>
      <div id="panzoom" style="text-align: center">
        <img src="http://blog.millermedeiros.com/wp-content/uploads/2010/04/awesome_tiger.svg" width="900" height="900">
      </div>
    </section>
    <section class="buttons">
      <button class="zoom-in">Zoom In</button>
      <button class="zoom-out">Zoom Out</button>
      <input type="range" class="zoom-range">
      <button class="reset">Reset</button>
    </section>
    <script>
      $("#panzoom").panzoom({
        $zoomIn: $(".zoom-in"),
        $zoomOut: $(".zoom-out"),
        $zoomRange: $(".zoom-range"),
        $reset: $(".reset")
      });
    </script>
  </body>
</html>

Open in new window

0
 

Author Comment

by:coolispaul
ID: 39277311
Hi sedgwick

Where are the left/right/up/down buttons?

Thanks
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39277315
u didn't say anything about left/right/up/down buttons.
0
 

Author Comment

by:coolispaul
ID: 39277325
yeah i meant buttons for panning not zooming

I want to create left/right up /down buttons instead of the dragging...

Thanks
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39277459
<!doctype html>
<html>
  <head>
    <title>Panzoom for jQuery</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
      section { text-align: center; margin: 50px 0; }
    </style>
  </head>
  <body>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
	<script src="jquery.panzoom.min.js"></script>
    <section>
      <h1>Panning and zooming with CSS3</h1>
      <div id="panzoom" style="text-align: center">
        <img src="http://blog.millermedeiros.com/wp-content/uploads/2010/04/awesome_tiger.svg" width="900" height="900">
      </div>
    </section>
    <section class="buttons">
		<button onclick="panleft()">Left</button>
		<button onclick="panright()">right</button>
		<button onclick="pantop()">up</button>
		<button onclick="panbottom()">bottom</button>
      <button class="zoom-in">Zoom In</button>
      <button class="zoom-out">Zoom Out</button>
      <input type="range" class="zoom-range">
      <button class="reset">Reset</button>
    </section>
    <script>
      $("#panzoom").panzoom({
        $zoomIn: $(".zoom-in"),
        $zoomOut: $(".zoom-out"),
        $zoomRange: $(".zoom-range"),
        $reset: $(".reset")
      });
	  
	  function panleft(){
		$('#panzoom img').animate({
			marginLeft: "-=0.5in"
		}, 1000, function() {
		});
	  }
	  
	  function panright(){
		$('#panzoom img').animate({
			marginLeft: "+=0.5in"
		}, 1000, function() {
		});
	  }
	  
	  function pantop(){
		$('#panzoom img').animate({
			marginTop: "-=0.5in"
		}, 1000, function() {
		});
	  }
	  
	  function panbottom(){
		$('#panzoom img').animate({
			marginTop: "+=0.5in"
		}, 1000, function() {
		});
	  }
    </script>
  </body>
</html>

Open in new window

0
 

Author Comment

by:coolispaul
ID: 39277502
ok thnaks that works nicely,

there seems to be some delay but i can fiddle with this

Thanks
0
 
LVL 16

Expert Comment

by:hankknight
ID: 39278244
This is now officially supported!

In response to this request, the author of this jquery.panzoom created official support for this:

https://github.com/timmywil/jquery.panzoom/commit/6a735238f98f7cc3283f07d14a3b0eb56bf7b4bb
jq.panzoom.js
0
 
LVL 16

Expert Comment

by:hankknight
ID: 39281123
Here is a working example using the latest official code:

http://jsfiddle.net/timmywil/Khvrj/2/
0
 

Author Comment

by:coolispaul
ID: 39281534
Great thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now