jquery-mousewheel修复最大值 [英] jquery-mousewheel fix maximum value
问题描述
我在使用brandonaaron jquery-mousewheel插件
https://github.com/brandonaaron/jquery-mousewheel
在 Pan Zoom 。
问题是我无法修复最大值值无限地向下滚动并向上滚动。
我该如何解决这个问题。
我已经尝试了简单的功能,但是我无法在这里制作鼠标滚轮。
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;
如何在鼠标滚轮功能中给出最大值和最小值
该插件没有缩放级别的概念 - 所以这种方法无效。相反,它会不断放大/缩小,并根据图像的当前尺寸跟踪状态 - 在缩放时它会增加/减少。
您可以限制您可以使用min_width和min_height选项缩放多远 - 目前max未实现,但同样的逻辑可用于添加max_width和max_height。
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
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.
这篇关于jquery-mousewheel修复最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!