Solved

jQuery PanZoom

Posted on 2013-06-23
9
1,283 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

746 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

14 Experts available now in Live!

Get 1:1 Help Now