我有这段代码:
F.onmousewheel = function (e) {
zoomFactor = {10: 10.1, 10.1: 10.2, 10.2: 10.3, 10.3: 10.4, 10.4: 10.5, 10.5: 10.6, 10.6: 10.7, 10.7: 10.8, 10.8: 10.9, 10.9: 11, 11: 10}[zoomFactor];
};
我用鼠标滚轮使用它。
当我向下和向上滚动时,zoomFactor更大。但我希望它向上滚动 - zoomFactor较低,当向下滚动时,zoomFactor可能会更大。我尝试使用zoomFactor = {10: 10.1, 10.1: 10.2, 10.2: 10.3, 10.3: 10.2, 10.2: 10.1, 10.1: 10}
,但是当我达到10.1并再次滚动时,它不是10.2而是10!
我不知道。请让我知道如何使用此代码的向下滚动功能!谢谢!
答案 0 :(得分:0)
我解决了我的问题,但还有另一个问题。
F.onmousewheel = function (e) {
if (e.wheelDelta > 0) {
zoomFactor = {10: 10.1, 10.1: 10.2, 10.2: 10.3, 10.3: 10.4, 10.4: 10.5, 10.5: 10.6, 10.6: 10.7, 10.7: 10.8, 10.8: 10.9, 10.9: 11}[zoomFactor];
} else {
zoomFactor = {11: 10.9, 10.9: 10.8, 10.8: 10.7, 10.7: 10.6, 10.6: 10.5, 10.5: 10.4, 10.4: 10.3, 10.3: 10.2, 10.2: 10.1, 10.1: 10}[zoomFactor];
}
};
当我达到值11并再次滚动时,我收到错误。是否有选项可以停在价值11?