smooth scrolling
This commit is contained in:
1 file changed
+24
-4
@@ -5,23 +5,34 @@ import Asteria
|
||||
Rectangle {
|
||||
focus: true
|
||||
|
||||
// Animation for smooth scrolling
|
||||
property Animation scrollAnimation: PropertyAnimation {
|
||||
target: chunkListView
|
||||
property: "contentY"
|
||||
duration: 200
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
|
||||
// Public methods for global keyboard navigation
|
||||
function handlePageUp() {
|
||||
var scrollAmount = chunkListView.height * 0.95;
|
||||
chunkListView.contentY = Math.max(0, chunkListView.contentY - scrollAmount);
|
||||
var targetY = Math.max(0, chunkListView.contentY - scrollAmount);
|
||||
animateScrollTo(targetY);
|
||||
}
|
||||
|
||||
function handlePageDown() {
|
||||
var scrollAmount = chunkListView.height * 0.95;
|
||||
var maxY = Math.max(0, chunkListView.contentHeight - chunkListView.height);
|
||||
chunkListView.contentY = Math.min(maxY, chunkListView.contentY + scrollAmount);
|
||||
var targetY = Math.min(maxY, chunkListView.contentY + scrollAmount);
|
||||
animateScrollTo(targetY);
|
||||
}
|
||||
|
||||
function handleScrollUp() {
|
||||
// Scroll up by approximately 2-3 lines
|
||||
var lineHeight = appState.fontSize * appState.lineSpacing;
|
||||
var scrollAmount = lineHeight * 3; // ~2-3 lines
|
||||
chunkListView.contentY = Math.max(0, chunkListView.contentY - scrollAmount);
|
||||
var targetY = Math.max(0, chunkListView.contentY - scrollAmount);
|
||||
animateScrollTo(targetY);
|
||||
}
|
||||
|
||||
function handleScrollDown() {
|
||||
@@ -29,7 +40,16 @@ Rectangle {
|
||||
var lineHeight = appState.fontSize * appState.lineSpacing;
|
||||
var scrollAmount = lineHeight * 3; // ~2-3 lines
|
||||
var maxY = Math.max(0, chunkListView.contentHeight - chunkListView.height);
|
||||
chunkListView.contentY = Math.min(maxY, chunkListView.contentY + scrollAmount);
|
||||
var targetY = Math.min(maxY, chunkListView.contentY + scrollAmount);
|
||||
animateScrollTo(targetY);
|
||||
}
|
||||
|
||||
// Helper function to animate scrolling
|
||||
function animateScrollTo(targetY) {
|
||||
// Stop any ongoing animation
|
||||
scrollAnimation.stop();
|
||||
scrollAnimation.to = targetY;
|
||||
scrollAnimation.start();
|
||||
}
|
||||
|
||||
gradient: Gradient {
|
||||
|
||||
Reference in new issue
Block a user