Trying to create a viewport (in android app) that swipes horizontally through a photo album. I want it to snap to each photo rather than stop halfway between photos. Tried viewPort.setSingleStepSizes(area.getWidth(),0); but didn’t work because it seems to only work with buttons.
Thanks I was able to write this function and it worked nicely.
void MyCustomViewPort::visibleAreaChanged (const Rectangle<int>& newVisibleArea)
{
if(isCurrentlyScrollingOnDrag())
return;
Component * c = getViewedComponent();
int width = c->getLocalBounds().getHeight(); // my components are square, so height = width
int x = newVisibleArea.getX();
int p = x % width;
x += p >= width / 2 ? width-p : -p;
setViewPosition (x, 0);
}