mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 10:14:52 +02:00
Implement auto-scrolling on Places cards (TODO for Connections)
This commit is contained in:
parent
079b276c2b
commit
4cee6b720a
2 changed files with 48 additions and 3 deletions
|
@ -41,6 +41,8 @@ Column {
|
|||
property var goFunction: null;
|
||||
property var http: null;
|
||||
|
||||
property bool autoScrollTimerEnabled;
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
Component.onCompleted: suggestions.getFirstPage();
|
||||
HifiModels.PSFListModel {
|
||||
|
@ -102,9 +104,12 @@ Column {
|
|||
id: scroll;
|
||||
model: suggestions;
|
||||
orientation: ListView.Horizontal;
|
||||
highlightFollowsCurrentItem: false
|
||||
highlightMoveDuration: -1;
|
||||
highlightMoveVelocity: -1;
|
||||
highlightFollowsCurrentItem: true;
|
||||
preferredHighlightBegin: 0;
|
||||
preferredHighlightEnd: cardWidth;
|
||||
highlightRangeMode: ListView.StrictlyEnforceRange;
|
||||
highlightMoveDuration: 800;
|
||||
highlightMoveVelocity: 1;
|
||||
currentIndex: -1;
|
||||
|
||||
spacing: 12;
|
||||
|
@ -137,5 +142,43 @@ Column {
|
|||
hoverThunk: function () { hovered = true }
|
||||
unhoverThunk: function () { hovered = false }
|
||||
}
|
||||
|
||||
onCountChanged: {
|
||||
if (scroll.currentIndex === -1 && scroll.count > 0 && root.autoScrollTimerEnabled) {
|
||||
scroll.currentIndex = 0;
|
||||
autoScrollTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: feedMouseArea;
|
||||
enabled: root.autoScrollTimerEnabled;
|
||||
anchors.fill: parent;
|
||||
hoverEnabled: true;
|
||||
onEntered: {
|
||||
if (autoScrollTimer.running) {
|
||||
autoScrollTimer.stop();
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
autoScrollTimer.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: autoScrollTimer;
|
||||
interval: 3000;
|
||||
running: false;
|
||||
repeat: true;
|
||||
onTriggered: {
|
||||
if (scroll.currentIndex !== -1) {
|
||||
if (scroll.currentIndex === scroll.count - 1) {
|
||||
scroll.currentIndex = 0;
|
||||
} else {
|
||||
scroll.currentIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,6 +325,7 @@ StackView {
|
|||
filter: addressLine.text;
|
||||
goFunction: goCard;
|
||||
http: http;
|
||||
autoScrollTimerEnabled: true;
|
||||
}
|
||||
Feed {
|
||||
id: places;
|
||||
|
@ -337,6 +338,7 @@ StackView {
|
|||
filter: addressLine.text;
|
||||
goFunction: goCard;
|
||||
http: http;
|
||||
autoScrollTimerEnabled: true;
|
||||
}
|
||||
Feed {
|
||||
id: snapshots;
|
||||
|
|
Loading…
Reference in a new issue