Merge pull request #10447 from davidkelly/dk/smoothScrollFeed

animate scroll of partially visible cards
This commit is contained in:
Howard Stearns 2017-05-12 10:13:49 -07:00 committed by GitHub
commit 63f2a1061a

View file

@ -238,8 +238,25 @@ 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: 250;
}
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;
scroll.currentIndex = index;
anim.running = true;
}
}