dashboard: fix scrolling between panes
This commit is contained in:
parent
88d70a7f22
commit
e47579c58d
1 changed files with 3 additions and 9 deletions
|
|
@ -87,7 +87,6 @@ Item {
|
||||||
id: row
|
id: row
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
index: 0
|
|
||||||
sourceComponent: Dash {
|
sourceComponent: Dash {
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
state: root.state
|
state: root.state
|
||||||
|
|
@ -96,19 +95,16 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
index: 1
|
|
||||||
sourceComponent: Media {
|
sourceComponent: Media {
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
index: 2
|
|
||||||
sourceComponent: Performance {}
|
sourceComponent: Performance {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
index: 3
|
|
||||||
sourceComponent: Weather {}
|
sourceComponent: Weather {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -134,14 +130,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
component Pane: Loader {
|
component Pane: Loader {
|
||||||
required property int index
|
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
Component.onCompleted: active = Qt.binding(() => {
|
Component.onCompleted: active = Qt.binding(() => {
|
||||||
const current = view.currentIndex;
|
const vx = Math.floor(view.visibleArea.xPosition * view.contentWidth);
|
||||||
// Activate current pane and adjacent panes for smooth scrolling
|
const vex = Math.floor(vx + view.visibleArea.widthRatio * view.contentWidth);
|
||||||
return Math.abs(index - current) <= 1;
|
return (vx >= x && vx <= x + implicitWidth) || (vex >= x && vex <= x + implicitWidth);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue