简体   繁体   English

iScroll 4 –恢复默认/原生缩放功能

[英]iScroll 4 – restore the default/native zoom feature

I have a setup where my scrollable container takes the full width and height of the viewport. 我有一个设置,其中可滚动容器使用视口的整个宽度和高度。 I use iScroll to scroll the content over a background image. 我使用iScroll在背景图像上滚动内容。 Works fine so far and I didn't find a better solution to have a fixed background image (any ideas would be awesome :) ). 到目前为止运行良好,我没有找到更好的解决方案来固定背景图像(任何想法都很棒:))。 The problem is, that I can't zoom into the page anymore, cause iScroll disables it for the scrollable container, which is in this case the whole screen. 问题是,我无法再放大页面,原因是iScroll禁用了可滚动容器(在本例中为整个屏幕)。 Is there a way to get the native zoom feature back? 有没有办法找回原生缩放功能? I would also take a "desperate" solution which modifies the iScroll library or even another library for scrolling. 我还将采用一个“绝望的”解决方案,该解决方案修改了iScroll库甚至另一个用于滚动的库。

For most mobile you won't be able to get the native zoom since iScroll overrides the touchstart and touchmove events. 对于大多数移动设备,您将无法获得原生缩放,因为iScroll会覆盖touchstart和touchmove事件。 You can however have the simulated version of it by turning on the zoom option . 但是,您可以通过打开zoom选项获得其模拟版本。

From the documentation : 从文档中

var myScroll = new iScroll('wrapper', { zoom: true });

So I've found a pretty nice solution, which is built into iOS5: 因此,我找到了一个不错的解决方案,它内置于iOS5中:

overflow: scroll;
-webkit-overflow-scrolling: touch;

That did the trick for my case. 这对我的情况起到了作用。 No need for an extra scrolling library and it has the same features as before (momentum scrolling, resizing and so on). 不需要额外的滚动库,它具有与以前相同的功能(动量滚动,调整大小等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM