Results 1 to 9 of 9

Thread: Powerzoom Inside a Fancybox

  1. #1
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Powerzoom Inside a Fancybox

    http://www.dynamicdrive.com/dynamici...owerzoomer.htm

    Hi

    I'm trying to get powerzoomer inside a Fancybox from http://fancyapps.com/fancybox/

    I can get an image to display & firebug is not reporting any errors, when hovering over the image nothing happens.

    This is my code it preceded by links to jquery fancybox and ddpowerzoom


    Code:
    <script type="text/javascript">
    jQuery(document).ready(function($) {
      $('#Pzoom').fancybox({
            beforeShow : function() { 
                $('#fancybox-img').wrap(
                $('<a />')
               .attr('href', this.href) // this.href gets the "href" of the current image
               .addClass('power-zoom')
               .attr('rel', "position: 'inside'")
               .attr('id', "listenmusic")
      
        ); // wrap
            AddZoom('#listenmusic')
            } //BeforeShow
            }); //Pzoom
     
          
    }) ; // ready
     
    function AddZoom(Selector)
        {
        alert  ("AddZoom " + Selector)
       jQuery(Selector).addpowerzoom({
                       defaultpower: 2,
                       powerrange: [2,5],
                       largeimage: null,
                       magnifiersize: [100,100] //<--no comma following last option!
     
              });
       }
    </script>

    Thanx Holly
    Last edited by jscheuer1; 08-21-2012 at 08:01 AM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    a is not a self closing tag, that could present problems in at least some browsers, try writing it out (<a></a>). You should check in a DOM inspector or equivalent (something that shows the DOM tree of the page including any modifications made via javascript) to see if your created element is there. Perhaps use a different id each time. Investigate whether or not the created element is retained. If it is, you will have nested a tags within each other, that would cause problems.

    You could always use FancyBox to present an iframe with the zoom script set up inside it.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi

    Taking your suggestion on board I've reworked the the code so that fancybox calls an iframe and the zoom script is fireing from within the iframe. However it is still not working the image appears but the is no magnification on mouse hover.

    I'm unable to show you a live website as i'm at the developent stage which is also why id's etc are hard coded. I can upload the two files the first img.html contains jQuery / Fancybox Code sending a link to GetImg.php that has the zoom code.

    it seems that if i don't load the jquery.js inside the iframe firebug reports an error saying $ or jQuery is a function I also had ddpowerzoomer.js in the parent file but that didn't make any differance either.

    I'd apreciate if some one would be kind enough to look and tell me what i'm doing wrong and there isn't some kind of incompatilbility between fancybox and powerzoomer

    Thanx for your help

    Holly
    img.htm

    Code:
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title></title>
          <!-- Add jQuery library -->
    	<script type="text/javascript" src="fancyBox-2.0.6/lib/jquery-1.7.2.min.js"></script>
        <!-- Add mousewheel plugin (this is optional) -->
        <script type="text/javascript" src="fancyBox-2.0.6/lib/jquery.mousewheel-3.0.6.pack.js"></script>
    
        <!-- Add fancyBox main JS and CSS files -->
        <script type="text/javascript" src="fancyBox-2.0.6/source/jquery.fancybox.js?v=2.0.6"></script>
        <link rel="stylesheet" type="text/css" href="fancyBox-2.0.6/source/jquery.fancybox.css?v=2.0.6" media="screen" />
    
        <!-- Add Button helper (this is optional) -->
        <link rel="stylesheet" type="text/css" href="fancyBox-2.0.6/source/helpers/jquery.fancybox-buttons.css?v=1.0.2" />
        <script type="text/javascript" src="fancyBox-2.0.6/source/helpers/jquery.fancybox-buttons.js?v=1.0.2"></script>
    
        <!-- Add Thumbnail helper (this is optional) -->
        <link rel="stylesheet" type="text/css" href="fancyBox-2.0.6/source/helpers/jquery.fancybox-thumbs.css?v=1.0.2" />
        <script type="text/javascript" src="fancyBox-2.0.6/source/helpers/jquery.fancybox-thumbs.js?v=1.0.2"></script>
    
        <!-- Add Media helper (this is optional) -->
        <script type="text/javascript" src="fancyBox-2.0.6/source/helpers/jquery.fancybox-media.js?v=1.0.0"></script>
        
        
        <script type="text/javascript">
         jQuery(document).ready(function($){
         	$("#fancybox-manual-b").click(function() {
    				$.fancybox.open({
    					href : 'GetImg.php?img=/images/listenmusic.jpg',
    					type : 'iframe',
    					padding : 5
    				});
    			});
         
         }) ; // ready 
        </script>     
     
      </head>
      <body>
                  
                  <p>
                 <a id="fancybox-manual-b" href="javascript:;" title="A witty Title">Graphic A</a>
                  </p>
      </body>
    </html>
    GetImg.php

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title>Holly Gibbons</title>
    <script type="text/javascript" src="fancyBox-2.0.6/lib/jquery-1.7.2.min.js"></script>
        
          <script type="text/javascript" src="/js/ddpowerzoomer.js"></script>    
        <script type="text/javascript">
         	jQuery('#image3').addpowerzoom({
             		defaultpower: 2,
          		powerrange: [2,5],
          		largeimage: null,
          		magnifiersize: [100,100] //<--no comma following last option!
    
    				}); 
        </script>
      </head>
      <body>
      <?php 
      $my_img = $_GET['img'];
      ?>
    <p> <img id="image3" src = <?php echo $my_img ?> /></p>
    </html>

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    for GetImg.php:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title>Holly Gibbons</title>
    <script type="text/javascript" src="fancyBox-2.0.6/lib/jquery-1.7.2.min.js"></script>
        
          <script type="text/javascript" src="/js/ddpowerzoomer.js"></script>    
        <script type="text/javascript">
        jQuery(function($){
        	$('#image3').addpowerzoom({
        		defaultpower: 2,
        		powerrange: [2,5],
        		largeimage: null,
        		magnifiersize: [100,100] //<--no comma following last option!  
        	}); 
        });
        </script>
      </head>
      <body>
      <?php 
      $my_img = $_GET['img'];
      ?>
    <p> <img id="image3" src = <?php echo $my_img ?> /></p>
    </html>
    The browser cache may need to be cleared and/or the page refreshed to see changes.
    Last edited by jscheuer1; 08-21-2012 at 05:19 PM. Reason: Format
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    HollyG (08-22-2012)

  6. #5
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanx That worked!

  7. #6
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Any suggestions why on mouse scroll I can zoom in but not out again?

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That could be because there was a change in the way jQuery handles mousewheel events. You may need to downdate the version of jQuery used on the GetImg.php page to:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    Give that a try and let me know.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #8
    Join Date
    Aug 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanx changing the jQuery version worked!
    However have a feeling this will end in tears, Because when i've sorted out an incorrect iframe re-size issue i'll be putting this on a wordpress site that uses yet a differant version of jQuery.

    Thanx again
    Holly

  10. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If that's an issue, try this modified version of the script:

    ddpowerzoomer.js

    Test it out with the later version of jQuery just to be sure. I just did and it's working fine here.
    Last edited by jscheuer1; 08-25-2012 at 05:10 AM. Reason: tested it
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •