3 ms·
I've thought about this before - where you have a 2D array of images with infinite scroll in all directions. You need to track the scroll position, and kill th
by bduerst 13y ago
I've thought about this before - where you have a 2D array of images with infinite scroll in all directions.
You need to track the scroll position, and kill the elements that are scrolling away as you create the new elements in the direction you are scrolling - with the entire purpose of creating enough cached images so that it is seamless to the user.
The problem is that the scroll position changes back when you kill the old elements, so you need to keep a running tally of the matrix somewhere to track the user's position.
- EGreg 13y agoYou could solve a lot of problems with position: absolute and javascript, which you assume is on. A bigger problem is that mobile safari doesn't let you execute js during scroll. One way around that is by hsing iScroll which fakes scrolling using CSS.
- Encosia 13y agoYou can use the touchmove event to do things while mobile safari scrolls.
- EGreg 13y agoReally? http://stackoverflow.com/questions/10482227/javascript-dom-changes-in-touchmove-delayed-until-scroll-ends-on-mobile-safari/10856671#10856671 http://stackoverflow.com/questions/10482227/javascript-dom-c...
- Encosia 13y agoLooking back at the code that I was thinking of, it looks like I was using requestAnimationFrame to do the actual DOM manipulation (based on a variable that was updated in touchmove). Maybe Mobile Safari still allows DOM manipulation during those animation frame callbacks, even if touchmove is happening?
- mikaraento 13y agoThat's right: a) you don't get scroll events until the scroll has finished, b) you do get touch events that drive the scroll (but nothing during the inertial part), c) the appearance of the page is not updated until the scroll has finished. You can get around this by using programmatic scrolling (e.g., iScroll, zynga-scroller) but you'll never get quite as nice scrolling as with the native behaviour.
- myfonj 13y agoI suppose that’s the way most maps operate: loads map tiles and anchors current viewport properties in URL. Difference is that there is no 'real scroll position with real scrollbar'.