【问题标题】:Enabling pinch zoom on iOS when using iScroll.js使用 iScroll.js 时在 iOS 上启用捏合缩放
【发布时间】:2015-03-23 15:01:27
【问题描述】:

我正在使用iScroll.js 构建一个单页可滚动Web 应用程序,但无论我做什么,它的内置缩放功能都无法正常工作。我包含了 iscroll-zoom.js 文件,但仍然没有成功。

我的文件头中有这个:

<script src="js/iscroll.js"></script>
<script src="js/iscroll-zoom.js"></script>
<script src="js/iscroll-probe.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

还有这个脚本:

function loaded () {
myScroll = new IScroll('#wrapper', { 
    mouseWheel: true,
    zoom: true,
    bounce: false 
});

根据iScroll Documentation,这应该可以工作,但不能。如果有帮助,我需要在 iPad 上运行它。

【问题讨论】:

  • 你满足 CSS 要求了吗? “将位置:相对或绝对添加到滚动容器(包装器)。仅此一项通常可以解决大多数错误计算的包装器尺寸问题。”
  • 我确实有,这是代码:#wrapper { position: absolute; z-index: 1; top: 0px; bottom: 0px; left: 0; width: 100%; overflow: hidden; }

标签: javascript jquery html zooming iscroll


【解决方案1】:
function createZoomForID (id) {
    $timeout(function(){
        var wrapper = document.getElementById(id);
        var myScroll = new IScrollZ(wrapper, {
            zoom: true,
            zoomMin: 1,
            zoomMax: 4,
            scrollX: true,
            scrollY: true,
            mouseWheel: true,
            freeScroll: true,
            wheelAction: 'zoom',
        });
        $scope[id] = myScroll;
    }, 125);
}

【讨论】:

    猜你喜欢
    • 2011-10-31
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 2012-01-29
    • 2011-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多