Question

I've noticed on web and mobile apps, when scrolling down to the bottom of a list with thousands of entries it reaches the bottom instantly but appears to be scrolling through every entry.

How is this visual effect achieved? What is the common way to implement this simulation of fast-scroll?

Était-ce utile?

La solution

In software, just as in movies, illusion of movement is created by presenting frames in quick succession. If you want to create the illusion of scrolling from item 1 to item 1000 in a second, you divide the number of items to scroll by the frame rate (e.g. 60fps) and move by a corresponding number of items (possibly fractional) for each frame. For example, if your first frame had item 1 at the top, next has item 17, and so on, you'll be at 1000 after approximately one second.

Autres conseils

With memory.

So long as you have more memory than your monitor requires you can render things that aren't on the screen yet. When you load a webpage the scroll bar thumb starts to shrink as the page grows off the screen. Just because it's off the screen doesn't mean it isn't rendered in memory. Then to scroll to any position all that has to change is the pointer to where in memory the top left of your window is. This will change what memory is scanned to display in the window. 1 or 1,000 or 1,000,000 if you have it rendered in memory already it's very little work to jump around. This is memory intensive not CPU intensive. It only gets CPU intensive if you don't have that much memory and have to swap things out as they scroll around.

If you have the memory, fast scroll isn't simulated at all. It's just that fast.

Licencié sous: CC-BY-SA avec attribution
scroll top