Timeline: Bind to Flickable's width for scrolling

The setup of ScrollView and Flickable will otherwise generate a spurious
contentX change that messes up our range position.

Change-Id: I04f41b206a7ef4f0a889448f36103f427d1330d7
Task-number: QTCREATORBUG-19656
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Ulf Hermann
2018-01-31 14:08:39 +01:00
parent e43668f603
commit 0f32727097

View File

@@ -68,7 +68,6 @@ ScrollView {
// switch to non-interactive ourselves, though. // switch to non-interactive ourselves, though.
property bool stayInteractive: true property bool stayInteractive: true
onStayInteractiveChanged: flick.interactive = stayInteractive onStayInteractiveChanged: flick.interactive = stayInteractive
onWidthChanged: scroll()
Flickable { Flickable {
id: flick id: flick
@@ -89,6 +88,15 @@ ScrollView {
recursionGuard = false; recursionGuard = false;
} }
// Logically we should bind to scroller.width above as we use scroller.width in scroll().
// However, this width changes before scroller.width when the window is resized and if we
// don't explicitly set contentX here, for some reason an automatic change in contentX is
// triggered after this width has changed, but before scroller.width changes. This would be
// indistinguishabe from a manual flick by the user and thus changes the range position. We
// don't want to change the range position on resizing the window. Therefore we bind to this
// width.
onWidthChanged: scroll()
// Update the zoom control on scrolling. // Update the zoom control on scrolling.
onContentXChanged: guarded(function() { onContentXChanged: guarded(function() {
var newStartTime = contentX * zoomer.rangeDuration / scroller.width var newStartTime = contentX * zoomer.rangeDuration / scroller.width