0

I am using brandonaaron jquery-mousewheel plugin in

https://github.com/brandonaaron/jquery-mousewheel

with a zoom function on Pan Zoom.

The problem is i cant fix a maximum value to infinely scroll down and scroll up. How can i fix this problem.

I have tried it simple function but i cant able to make mouse wheel here

var zoomLevel = 100;
var maxZoomLevel = 105;
var minZoomLevel = 95;

function zoom(zm) {
 var img=document.getElementById("pic");
 if(zm > 1){
    if(zoomLevel < maxZoomLevel){
        zoomLevel++;
    }else{
        return;
    }
 }else if(zm < 1){
    if(zoomLevel > minZoomLevel){
        zoomLevel--;
    }else{
        return;
    }
 }
 wid = img.width;
 ht = img.height;
 img.style.width = (wid*zm)+"px";
 img.style.height = (ht*zm)+"px";
 img.style.marginLeft = -(img.width/2) + "px";
 img.style.marginTop = -(img.height/2) + "px";
}​

How to give maximum value and minimum value in mousewheel function

Vivek Dragon
  • 2,218
  • 4
  • 27
  • 48

1 Answers1

0

the plugin doesn't have a concept of a zoomlevel - so this approach won't work. Instead, it continually zooms in/out and tracks state by the current size of the image - which it increases/decreases as you zoom.

You can limit how far 'out' you can zoom with the min_width and min_height options - currently max is not implemented, but the same logic could be used to add max_width and max_height too.

benlumley
  • 11,370
  • 2
  • 40
  • 39