문제

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