mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-22 20:04:32 +08:00
Add property autoResetScroll to FluScrollablePage
I use it in my app, I think it can be useful to integrate the featurein the main project. This property autoResetScroll if true reset the scroll at the top when the StackView.onActivated is called. So the first time a page is view but also when the user go back in the stack.
This commit is contained in:
parent
d82e0ed529
commit
3eaaa228d8
@ -5,8 +5,11 @@ import QtQuick.Controls 2.15
|
|||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
FluPage {
|
FluPage {
|
||||||
|
property bool autoResetScroll: false
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
|
|
||||||
Flickable{
|
Flickable{
|
||||||
|
id: flickable
|
||||||
clip: true
|
clip: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ScrollBar.vertical: FluScrollBar {}
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
@ -17,4 +20,14 @@ FluPage {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetScroll() {
|
||||||
|
flickable.contentY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
StackView.onActivated: {
|
||||||
|
if (autoResetScroll) {
|
||||||
|
resetScroll(); // Call this function to reset the scroll position to the top
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,11 @@ import QtQuick.Controls
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
FluPage {
|
FluPage {
|
||||||
|
property bool autoResetScroll: false
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
|
|
||||||
Flickable{
|
Flickable{
|
||||||
|
id: flickable
|
||||||
clip: true
|
clip: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ScrollBar.vertical: FluScrollBar {}
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
@ -17,4 +20,14 @@ FluPage {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetScroll() {
|
||||||
|
flickable.contentY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
StackView.onActivated: {
|
||||||
|
if (autoResetScroll) {
|
||||||
|
resetScroll(); // Call this function to reset the scroll position to the top
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user