Current location: Hot Scripts Forums » General Web Coding » JavaScript » Zoom Out Function


Zoom Out Function

Reply
  #1 (permalink)  
Old 10-09-09, 06:01 PM
demonwares demonwares is offline
New Member
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Zoom Out Function

I have an image that is 60,000 pixels wide so i sliced it into many pieces and use a code to reassemble them. The code below allows me to zoom in to the map and moves the scroll bars accordingly. I now need to figure out how to get my zoom out function to work. It properly zooms out but I have been unable to get the scroll bars to move with it. If anyone could help out it would be greatly appreciated. Thanks in advance.
Code:
	var zoom_percent = 50;
	var rows = 8;
	var cols = 16;	
	var enc_h = 500;
	var enc_w = 700;
	var images = document.images;
	var org_height = images[0].height;

function zoom_in(){
	percent = zoom_percent / 100;
	var w = document.images;
	var width = w[0].width; // find width of each image
	var height = w[0].height; // find height of each image
	var w_percent = width*percent; // find __ percent of width
	var h_percent = height*percent; // find __ percent of height
	var scrollTopOld = document.getElementById('image_box').scrollTop; // find current scrollbar possition 
	var scrollLeftOld = document.getElementById('image_box').scrollLeft; // find current scrollbar possition 
	// increase width and height on all images
	for ( var i in w ){
	   w[i].width = w[i].width + w_percent;
	   w[i].height = w[i].height + h_percent;
	} 
	document.getElementById('image_box').scrollTop = ((1+percent)*scrollTopOld) + ((percent/2)*enc_h);
	document.getElementById('image_box').scrollLeft = ((1+percent)*scrollLeftOld) + ((percent/2)*enc_w);
}

function zoom_out(){
	percent = zoom_percent / 100;
	var w = document.images;
	var width = w[0].width;
	var height = w[0].height;
	var w_percent = width*percent;
	var h_percent = height*percent;
	var scrollTopOld = document.getElementById('image_box').scrollTop; // find current scrollbar possition 
	var scrollLeftOld = document.getElementById('image_box').scrollLeft; // find current scrollbar possition 
	// Reduce width and height on all images
	
	if (w[0].height>org_height){
		for ( var i in w ){
		   w[i].width = w[i].width - w_percent;
		   w[i].height = w[i].height - h_percent;
	}
	// move scrollbars evenly with image

	} 
}
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[2005] StartPosition for CommonDialogs? tim8w Windows .NET Programming 10 01-08-09 03:39 AM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM


All times are GMT -5. The time now is 01:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.