PathView element with 1 item moves in wrong direction when dragged right
The shortest direction calculation used integer math to determine which direction to move. For an odd modelCount, the wrong direction could be chosen. For a modelCount of 1 it was particularly obvious. Task-number: QTBUG-21337 Change-Id: I5e75c74153a5b4c62d1536226cd0703dcae04178 Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
This commit is contained in:
parent
630a481854
commit
589d39ec6c
|
@ -1926,7 +1926,7 @@ void QQuickPathViewPrivate::snapToIndex(int index)
|
|||
|
||||
if (!duration) {
|
||||
tl.set(moveOffset, targetOffset);
|
||||
} else if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) {
|
||||
} else if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2.0)) {
|
||||
qreal distance = modelCount - targetOffset + offset;
|
||||
if (targetOffset > moveOffset) {
|
||||
tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance));
|
||||
|
@ -1935,7 +1935,7 @@ void QQuickPathViewPrivate::snapToIndex(int index)
|
|||
} else {
|
||||
tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
|
||||
}
|
||||
} else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2) {
|
||||
} else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2.0) {
|
||||
qreal distance = modelCount - offset + targetOffset;
|
||||
if (targetOffset < moveOffset) {
|
||||
tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance));
|
||||
|
|
Loading…
Reference in New Issue