Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top