Viewport Magnetic Snap to Page

I am trying to create a viewport that will snap its view between pages in a “magnetic” fashion rather than continuous free scrolling.

By creating a custom visibleAreaChanged() function I am able to snap the view but it is instant, not animated. This looks especially awkward when drag scrolling with inertia. Is there any way to get this magnetic behavior in a viewport? It is standard behavior for most apps with drag scrolling and seems weird that I can’t figure out the correct way to implement it with JUCE.

2 Likes

I’d be really interested as well. With dots for the pages, in an iOS manner.

I haven’t tested this but I imagine one semi unobtrusive way would be to subclass and override the mouse scroll function on the viewport class.

In that subclass manage a timer and when the mouse wheel moves, tracking / manage some animations to your desired snap points.