我想为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"
}
}
}你可以轻弹红色方块,它会撞到墙上,但它不会弹跳。
有什么建议吗?
发布于 2017-02-28 22:43:31
你试过boundsBehavior: Flickable.OvershootBounds吗?
当接近flickable的边界时,它会给你跳跃的过渡。唯一的问题是,元素可能会稍微超出限制。
看起来Flickable.StopAtBounds确实做到了它所说的:在没有反弹动画的边界上停止元素。
https://stackoverflow.com/questions/42511136
复制相似问题