jquery-mousewheel fix maximum value
Asked Answered
B

1

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

Backlash answered 26/12, 2012 at 12:26 Comment(2)
not 100% sure what you are trying to achieve? Are you trying to make it so that you can't zoom in or out beyond a certain level?Mansour
@Mansour yes thats what i am trying to implement hereBacklash
M
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.

Mansour answered 4/1, 2013 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.