Merge pull request #570 from gaetandezeiraud/feature-fluscrollablepage-reset-scroll

Add property autoResetScroll to FluScrollablePage
This commit is contained in:
zhuzichu 2024-11-17 15:11:42 +08:00 committed by GitHub
commit c9e0732f99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -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
}
}
} }

View File

@ -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
}
}
} }