我想为 Flickable
创建某种视觉"反向边缘"效果。但是边缘是一个硬边,就像墙壁一样,因此无法随时将内容拖动或轻弹。
这是一些代码,我设置了StopAtBounds
,但是我无法使用反弹式。
import QtQuick 2.7
import QtQuick.Controls 1.4
ApplicationWindow
{
visible: true
width: 800
height: 800
Flickable
{
anchors.fill: parent
contentWidth: bob.width
contentHeight: bob.height
rightMargin: 200
leftMargin: 200
topMargin: 200
bottomMargin: 200
// prevents bob from going outside of bounds,
// but now cant use `rebound` transition.
// so how to apply `Easing.OutBounce`
boundsBehavior: Flickable.StopAtBounds
Rectangle
{
id: bob
width: 600
height: 600
color: "red"
}
}
}
您可以轻弹红色正方形,然后撞到墙壁,但不会弹跳。
有什么建议?
您是否尝试过 boundsBehavior: Flickable.OvershootBounds
?
它为您提供了靠近闪烁的边界时的弹跳过渡。唯一的事情是元素可能会略有限制。
看来Flickable.StopAtBounds
确实可以做到的:在没有篮板动画的情况下停止元素。