Im trying to create a pinch-zoomable image using iScroll library. It works fine with small images but when I use images bigger than the screen I cannot scroll through them (I can on desktop browsers, but not on mobile!).

This link takes to a live example of this.

有帮助吗?

解决方案

I finally solved it myself. Turns out the sample iScroll provides initializes the scrolling div with document.addEventListener('DOMContentLoaded', loaded, false);, but when this event is fired images might not have been loaded so their size is reported as 0.

Simply replacing it with:

window.addEventListener('load', loaded, false);

fixes it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top