Skip to content

Commit

Permalink
Merge pull request #570 from gaetandezeiraud/feature-fluscrollablepag…
Browse files Browse the repository at this point in the history
…e-reset-scroll

Add property autoResetScroll to FluScrollablePage
  • Loading branch information
zhuzichu520 authored Nov 17, 2024
2 parents 4920407 + 3eaaa22 commit c9e0732
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Qt5/imports/FluentUI/Controls/FluScrollablePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import QtQuick.Controls 2.15
import FluentUI 1.0

FluPage {
property bool autoResetScroll: false
default property alias content: container.data

Flickable{
id: flickable
clip: true
anchors.fill: parent
ScrollBar.vertical: FluScrollBar {}
Expand All @@ -17,4 +20,14 @@ FluPage {
width: parent.width
}
}

function resetScroll() {
flickable.contentY = 0;
}

StackView.onActivated: {
if (autoResetScroll) {
resetScroll(); // Call this function to reset the scroll position to the top
}
}
}
13 changes: 13 additions & 0 deletions src/Qt6/imports/FluentUI/Controls/FluScrollablePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import QtQuick.Controls
import FluentUI

FluPage {
property bool autoResetScroll: false
default property alias content: container.data

Flickable{
id: flickable
clip: true
anchors.fill: parent
ScrollBar.vertical: FluScrollBar {}
Expand All @@ -17,4 +20,14 @@ FluPage {
width: parent.width
}
}

function resetScroll() {
flickable.contentY = 0;
}

StackView.onActivated: {
if (autoResetScroll) {
resetScroll(); // Call this function to reset the scroll position to the top
}
}
}

0 comments on commit c9e0732

Please sign in to comment.