I am using Cocos Creator 3
I have scroll view with 20 items.
I have created a window to show 5 items with a mask.
I would like to show 5 exact items all the time. Currently when the user stop the scroll some items display partially or getting cutoff by the mask.
Is there a way to stop the scroll view at specific points only instead of freely stopping at any point?
I think you need to do it by your own. You need to calculate correct stop position when user stop scroll.
As I did this:
when user scroll, I calculating the element index in the start of node (you probably need to get center element index). Then when user stop scrolling, I take last saved index of element and snap my container node to correct position by “index * offset between elements”.
here is code example of my project:
“snapToNearestLevel” calls when user stop to scroll (touchup event).
“calculateCurrentLevel” calls every time user scrolling.
to calculate element index I just take current container y position (top down scrolling)
and divide it by offset between elements.