Solved

jQuery PanZoom

Posted on 2013-06-23
9
1,419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bootstrap NavBar Not Working 2 31
Pass a js value to an html form 5 43
Can't see json data in ajax call to Highcharts 2 32
Output A single quote in a loop? 5 15
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: blockā€¦
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

752 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