animate scroll of partially visible cards

This commit is contained in:
David Kelly 2017-05-11 15:10:19 -07:00
parent e4df4369ad
commit ae5f9e4fb1

View file

@ -238,8 +238,24 @@ Column {
stackShadowNarrowing: root.stackShadowNarrowing;
shadowHeight: root.stackedCardShadowHeight;
hoverThunk: function () { scroll.currentIndex = index; }
unhoverThunk: function () { scroll.currentIndex = -1; }
hoverThunk: function () { scrollToIndex(index); }
unhoverThunk: function () { scrollToIndex(-1); }
}
}
NumberAnimation {
id: anim;
target: scroll;
property: "contentX";
duration: 500;
}
function scrollToIndex(index) {
anim.running = false;
var pos = scroll.contentX;
var destPos;
scroll.positionViewAtIndex(index, ListView.Contain);
destPos = scroll.contentX;
anim.from = pos;
anim.to = destPos;
anim.running = true;
}
}