Flickable snap behaviour
Hi,
I have a ListView that displays a full screen items. The default snap behaviour with “snapMode: ListView.SnapOneItem”, is that when I drag for, lets say, 10 pixel, the flickable goes to the next item.
What I would like to achieve is to start the snap after a drag of half the screen.
Is this possible ?
Thanks in advance
2 replies
Ok, I have some Ideas that might help
If you let go the automatic “snapMode: ListView.SnapOneItem”, you can implement the behaviour yourself.
I can think of something like this:
- property double initContentY;
- property double singleItemHeight;//set this somewhere
- onMovementStarted: {
- //save contentY to a custom property on your flickable
- initContentY = contentY
- }
- onMovementEnded: {
- //
- var middleOfItem = (contentY-initContentY)%singleItemHeight
- if( Math.abs(middleOfItem) > (singleItemHeight/2)) {//more than half an item was flicked
- contentY += ( singleItemHeight - middleOfItem)
- //increment contentY to flick to the next item
- }
- }
I’m pretty sure you’d have to handle signs properly there even before the remainder operator but I think that’s the right way to go…
You must log in to post a reply. Not a member yet? Register here!

