我已将 jQuery Panzoom 添加到我的项目中。我正在全屏显示图像,我想让用户能够在 iOS 设备上放大该图片。平移有效,但缩放无效,我不知道为什么。启用设备模拟后,它在 Chrome 调试监视器中也不起作用。
即使有演示,捏缩放似乎也不起作用。插件坏了,还是我傻?
https://github.com/timmywil/panzoom
我正在创建动态包含图像的 div。
zoomThumb: function (d, e) {
let $imgPopup = $('<div>').addClass('fullScreenImage').appendTo($('body')).fadeIn();
let $panzoom = $('<img>').attr('src', d.src.replace('Thumb/', '')).appendTo($imgPopup);
$panzoom.panzoom({ disableZoom: false});
// Mouse wheel zoom
$imgPopup.on('mousewheel.focal', function (e) {
e.preventDefault();
var delta = e.delta || e.originalEvent.wheelDelta;
var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
$panzoom.panzoom('zoom', zoomOut, {
animate: false,
focal: e
});
});
// Close button
$('<div>').append($('<i>').addClass('fa').addClass('fa-times')).appendTo($imgPopup).click(function () {
$imgPopup.fadeOut({ done: () => { $imgPopup.remove(); } });
});
e.stopPropagation();
}
.fullScreenImage {
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.8);
display: none;
}
.fullScreenImage > img {
margin: auto;
display: block;
width: 80%;
}
.fullScreenImage > div {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: bold;
transition: 0.3s;
}
.fullScreenImage > div:hover,
.fullScreenImage > div:focus {
color: #bbb;
text-decoration: none;
cursor: pointer;
}
你知道如何解决这个问题吗?