我在向上滑动时将网格项设置为向上动画,并删除动画停止功能上的相应项目。 但问题是在尝试删除第0个索引项时。当用动画移除第0个索引项时,整个屏幕向上移动而不是相应的项动画。 这有什么解决方案吗?
Item {
id: fake_drag
x:0
y:0
width: 288*scaleFactor
height: 215*scaleFactor
property bool isReleased: false
NumberAnimation {
id: animationY
target: fake_drag
property: "y"
from: mouseYValue;
to: -200
duration: 500
onStopped: {
console.log("removed index : ", indexValue)
favouriteapp.remove(indexValue)
}
}
MouseArea {
id: mouseArea
property int difference: 0
width: 288*scaleFactor
height: 215*scaleFactor
anchors.centerIn: parent
onPressed : {
itemInitialYPosition = mouseY
indexValue = index
}
drag.target: fake_drag_image
drag.axis: Drag.YAxis
onReleased: {
onceloaded = false;
}
onMouseYChanged: {
mouseYValue = mouseY
difference = itemInitialYPosition - mouseY
if(!onceloaded) {
if(itemInitialYPosition >= mouseY){
if(difference >= 25){
console.log("swipe..")
animationY.start()
onceloaded = true;
}
}
}
}
Image {
id: fake_drag_image
width: 64; height: 64
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
source: "images/Feature_Galary.png"
states: State {
when: mouseArea.drag.active
ParentChange { target: fake_drag_image; parent: itemid }
AnchorChanges { target: fake_drag_image; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
}
}
}
这是网格项委托中使用的代码。