Forums / Templates, Stylesheets, Page Layout / Script for floating the large image over smaller images on product info page

Script for floating the large image over smaller images on product info page

Locked

Views: 4,127

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
19 Jun 2009, 11:20 AM
#1
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Script for floating the large image over smaller images on product info page

Hi all
Here's the script I use as the override for tpl_modules_main_product_image.php. Now instead of javascript opening a clumsy window to view the full sized image, it appears as a floating image that tracks the mouse. Feel free to improve the code. It's based on a nettuts+ tutorial Jquery for Absolute Beginners - Day 11 - really great series of tutorials.
Don't forget to add the jquery file to your includes directory

CSS:

#largeImage {
	position:absolute;
	padding:0.5em;
	background:#e3e3e3;
	border: solid 1px #bfbfbf;
	}

tpl_modules_main_product_image.php

<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?>

<script type="text/javascript" src="includes/js/jquery.js"></script>

<script type="text/javascript">
$(function(){
	$('#productMainImage a').hover (function (e) {
	// mouse on
	var href=$(this).attr('href');
	$('<img id="largeImage" src="' +href+'" alt="image" />')
	.css('top', e.pageY + -120)
	.css('left', e.pageX + 40)
	.appendTo('body');
	},
	function (){
	// mouse off
	$('#largeImage').remove();
	});
	$('#productMainImage a' ).mousemove(function(e) {
		$('#largeImage')
		.css('top', e.pageY -120)
		.css('left', e.pageX + 40);
	})
});
</script>

<div id="productMainImage" class="centeredContent back">
<a href="<?php echo $products_image_large?> "><img id="jsImage" src="<?php echo $products_image_medium ?>" alt="Product Image"/>
<?php echo '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span>'?>

</a>
</div>
19 Jun 2009, 2:28 PM
#2
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Script for floating the large image over smaller images on product info page

Any chance of a working demo?

20 Jun 2009, 8:06 AM
#3
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Re: Script for floating the large image over smaller images on product info page

Yep, scroll down to day 11

nettuts.com/articles/web-roundups/jquery-for-absolute-beginners-video-series

and click view demo. My site isn't live yet so I hesitate to give out the url.
Steve

20 Jun 2009, 8:21 AM
#4
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Re: Script for floating the large image over smaller images on product info page

... and if anyone has the time to code displaying medium images (large might make the page loading too slow) when hovering over the thumbails in the product listings pages please post it. It's slightly trickier as the HTML is written into a variable. I haven't the time to work it out this week.
Thanks, Steve

20 Mar 2010, 9:17 PM
#5
ftdc avatar

ftdc

New Zenner

Join Date:
Oct 2009
Location:
Stockholm, Sweden
Posts:
16
Plugin Contributions:
0

Re: Script for floating the large image over smaller images on product info page

Really interesting I'm looking into doing some modifications on that page as well, but I'm really new on both Zen cart and Jquery I have found a great tut by sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery but i don't know how to get it to work with the product info page. I guess you need to get deep into changing the code and that's beyond my skills you seem to be knowing what you are doing pls help:frusty: