mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(view): add smooth scroll animation for keyboard navigation in NListView and NGridView
This commit is contained in:
@@ -112,6 +112,20 @@ Item {
|
||||
wheelScrollAnimation.restart();
|
||||
}
|
||||
|
||||
function animateToContentY(targetY) {
|
||||
const clampedY = root.clampScrollY(targetY);
|
||||
|
||||
if (!Settings.data.general.smoothScrollEnabled || Settings.data.general.animationDisabled || gridView.dragging || gridView.flicking) {
|
||||
gridView.contentY = clampedY;
|
||||
root._wheelTargetY = clampedY;
|
||||
return;
|
||||
}
|
||||
|
||||
root._wheelTargetY = clampedY;
|
||||
wheelScrollAnimation.to = clampedY;
|
||||
wheelScrollAnimation.restart();
|
||||
}
|
||||
|
||||
// Track selection index for gradient visibility (set externally)
|
||||
property int trackedSelectionIndex: -1
|
||||
|
||||
@@ -155,7 +169,25 @@ Item {
|
||||
|
||||
// Forward GridView methods
|
||||
function positionViewAtIndex(index, mode) {
|
||||
const shouldAnimate = mode === GridView.Contain;
|
||||
if (!shouldAnimate) {
|
||||
gridView.positionViewAtIndex(index, mode);
|
||||
root._wheelTargetY = gridView.contentY;
|
||||
return;
|
||||
}
|
||||
|
||||
const previousY = gridView.contentY;
|
||||
gridView.positionViewAtIndex(index, mode);
|
||||
const targetY = root.clampScrollY(gridView.contentY);
|
||||
|
||||
if (Math.abs(targetY - previousY) < 0.5) {
|
||||
root._wheelTargetY = targetY;
|
||||
return;
|
||||
}
|
||||
|
||||
gridView.contentY = previousY;
|
||||
root._wheelTargetY = previousY;
|
||||
root.animateToContentY(targetY);
|
||||
}
|
||||
|
||||
function positionViewAtBeginning() {
|
||||
|
||||
@@ -100,9 +100,41 @@ Item {
|
||||
wheelScrollAnimation.restart();
|
||||
}
|
||||
|
||||
function animateToContentY(targetY) {
|
||||
const clampedY = root.clampScrollY(targetY);
|
||||
|
||||
if (!Settings.data.general.smoothScrollEnabled || Settings.data.general.animationDisabled || listView.dragging || listView.flicking) {
|
||||
listView.contentY = clampedY;
|
||||
root._wheelTargetY = clampedY;
|
||||
return;
|
||||
}
|
||||
|
||||
root._wheelTargetY = clampedY;
|
||||
wheelScrollAnimation.to = clampedY;
|
||||
wheelScrollAnimation.restart();
|
||||
}
|
||||
|
||||
// Forward ListView methods
|
||||
function positionViewAtIndex(index, mode) {
|
||||
const shouldAnimate = mode === ListView.Contain;
|
||||
if (!shouldAnimate) {
|
||||
listView.positionViewAtIndex(index, mode);
|
||||
root._wheelTargetY = listView.contentY;
|
||||
return;
|
||||
}
|
||||
|
||||
const previousY = listView.contentY;
|
||||
listView.positionViewAtIndex(index, mode);
|
||||
const targetY = root.clampScrollY(listView.contentY);
|
||||
|
||||
if (Math.abs(targetY - previousY) < 0.5) {
|
||||
root._wheelTargetY = targetY;
|
||||
return;
|
||||
}
|
||||
|
||||
listView.contentY = previousY;
|
||||
root._wheelTargetY = previousY;
|
||||
root.animateToContentY(targetY);
|
||||
}
|
||||
|
||||
function positionViewAtBeginning() {
|
||||
|
||||
Reference in New Issue
Block a user