I started with an image that is over 60,000 px wide and sliced it into squares to decrease load time. I also decreased the size of the code so that the customer can zoom in and out to view the image. This image table is viewed in a fixed size div. The code below is the javascript i am using to zoom in and out.
The code works great for zooming in on the image by increasing the image size by 50% but I am trying to get the scrollbars to align properly so that it zooms in to one location and does not jump all over.Code:var zoom_percent = 50; var rows = 8; var cols = 16; var zoom_percent = 50; var rows = 8; var cols = 16; function zoom_in(){ 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; // 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; } // move scrollbars evenly with image var v_movement = (h_percent*rows)/2; document.getElementById('image_box').scrollTop = document.getElementById('image_box').scrollTop + v_movement; var h_movement = (w_percent*cols)/2; document.getElementById('image_box').scrollLeft = document.getElementById('image_box').scrollLeft + h_movement; } 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; // Reduce width and height on all images if (w[0].height>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 var v_movement = (h_percent*rows)/2; document.getElementById('image_box').scrollTop = document.getElementById('image_box').scrollTop - v_movement; var h_movement = (w_percent*cols)/2; document.getElementById('image_box').scrollLeft = document.getElementById('image_box').scrollLeft - h_movement; } }


LinkBack URL
About LinkBacks
Reply With Quote
icon below! (this is even better than "liking" a post)
