In order to disable mouse dragging in a Flickable, you need to set interactive to false first, then add a MouseArea to it as follows:
MouseArea
{
id: mousearea
anchors.fill: parent
//so that flickable won't steal mouse event
//however, when the flickable is flicking and interactive is true
//this property will have no effect until current flicking ends and interactive is set to false
//so we need to keep interactive false and scroll only with flick()
preventStealing: true
//scroll velocity
property real nextVelocity: 0
property real curWeight: baseWeight
property real baseWeight: 4
property real maxWeight: 12
property real stepWeight: 2
property real maxVelocity: 2400
property real minVelocity: -2400
Timer
{
id: timer
interval: 1000 / 60
repeat: false
running: false
onTriggered: parent.scroll()
}
function scroll()
{
var velocity = -parent.verticalVelocity + nextVelocity
parent.flickDeceleration = Math.abs(velocity) * 2.7
console.log(nextVelocity, parent.verticalVelocity, velocity)
parent.flick(0, velocity)
nextVelocity = 0
curWeight = baseWeight
}
onWheel:
{
wheel.accepted = true
var deltay = wheel.angleDelta.y
nextVelocity += curWeight * deltay
if(nextVelocity > maxVelocity)
nextVelocity = maxVelocity
else if(nextVelocity < minVelocity)
nextVelocity = minVelocity
curWeight += stepWeight
if(curWeight > maxWeight)
curWeight = maxWeight
timer.start()
}
//make sure items can only be clicked when view is not scrolling
//can be removed if you don't need this limitation
onPressed:
{
mouse.accepted = parent.moving ? true : false
}
onReleased:
{
mouse.accepted = parent.moving ? true : false
}
onClicked:
{
mouse.accepted = parent.moving ? true : false
}
}
This prevents mouse click from being propagated to the flickable, and scrolls with increasing velocity as you scroll the wheel faster, while keeping the flicking duration around a fixed number. You can adjust it to suit your needs.