aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/demos/photosurface/photosurface.qml4
-rw-r--r--src/quick/items/qquickflickable.cpp16
2 files changed, 17 insertions, 3 deletions
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml
index 8057bb8400..5d1445d776 100644
--- a/examples/quick/demos/photosurface/photosurface.qml
+++ b/examples/quick/demos/photosurface/photosurface.qml
@@ -181,7 +181,7 @@ Window {
radius: 2
antialiasing: true
height: flick.height * (flick.height / flick.contentHeight) - (width - anchors.margins) * 2
- y: flick.contentY * (flick.height / flick.contentHeight)
+ y: (flick.contentY - flick.originY) * (flick.height / flick.contentHeight)
NumberAnimation on opacity { id: vfade; to: 0; duration: 500 }
onYChanged: { opacity = 1.0; scrollFadeTimer.restart() }
}
@@ -197,7 +197,7 @@ Window {
radius: 2
antialiasing: true
width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2
- x: flick.contentX * (flick.width / flick.contentWidth)
+ x: (flick.contentX - flick.originY) * (flick.width / flick.contentWidth)
NumberAnimation on opacity { id: hfade; to: 0; duration: 500 }
onXChanged: { opacity = 1.0; scrollFadeTimer.restart() }
}
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index e0f8b6de00..3662827973 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -734,7 +734,19 @@ QQuickFlickable::~QQuickFlickable()
These properties hold the surface coordinate currently at the top-left
corner of the Flickable. For example, if you flick an image up 100 pixels,
- \c contentY will be 100.
+ \c contentY will increase by 100.
+
+ \note If you flick back to the origin (the top-left corner), after the
+ rebound animation, \c contentX will settle to the same value as \c originX,
+ and \c contentY to \c originY. These are usually (0,0), however ListView
+ and GridView may have an arbitrary origin due to delegate size variation,
+ or item insertion/removal outside the visible region. So if you want to
+ implement something like a vertical scrollbar, one way is to use
+ \c {y: (contentY - originY) * (height / contentHeight)}
+ for the position; another way is to use the normalized values in
+ \l {QtQuick::Flickable::visibleArea}{visibleArea}.
+
+ \sa originX, originY
*/
qreal QQuickFlickable::contentX() const
{
@@ -2153,6 +2165,8 @@ void QQuickFlickable::setRightMargin(qreal m)
This is usually (0,0), however ListView and GridView may have an arbitrary
origin due to delegate size variation, or item insertion/removal outside
the visible region.
+
+ \sa contentX, contentY
*/
qreal QQuickFlickable::originY() const