~ubuntu-weather-dev/ubuntu-weather-app/reboot-finish-listitem-migration

« back to all changes in this revision

Viewing changes to app/components/DayDelegate.qml

  • Committer: Victor Thompson
  • Date: 2015-10-18 21:11:01 UTC
  • mfrom: (56.1.87 reboot)
  • Revision ID: victor.thompson@gmail.com-20151018211101-vlyttyn2nloy7mwh
Merge of trunk and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
                    easing.type: Easing.InOutQuad
73
73
                    properties: "opacity"
74
74
                }
 
75
                ScriptAction {  // run animation to ensure the listitem fits
 
76
                    script: waitEnsureVisible.restart()
 
77
                }
75
78
            }
76
79
        },
77
80
        Transition {
165
168
        active: false
166
169
        anchors {
167
170
            bottomMargin: units.gu(2)
168
 
            left: parent.left
169
 
            leftMargin: units.gu(2)
170
 
            right: parent.right
171
 
            rightMargin: units.gu(2)
 
171
            horizontalCenter: parent.horizontalCenter
172
172
            top: mainInfo.bottom
173
173
        }
174
174
        asynchronous: true
180
180
 
181
181
    Behavior on height {
182
182
        NumberAnimation {
 
183
            id: heightAnimation
183
184
            easing.type: Easing.InOutQuad
184
185
        }
185
186
    }
186
187
 
 
188
    NumberAnimation {
 
189
        // animation to ensure the listitem fits by moving the contentY
 
190
        id: ensureVisibleAnimation
 
191
        easing.type: Easing.InOutQuad
 
192
        properties: "contentY"
 
193
        target: dayDelegate.parent.parent
 
194
    }
 
195
 
 
196
    Timer {
 
197
        id: waitEnsureVisible
 
198
        interval: 16
 
199
        repeat: false
 
200
 
 
201
        onTriggered: {
 
202
            // Only trigger once the loader has loaded
 
203
            // and the animations have stopped
 
204
            // otherwise restart the timer
 
205
            if (expandedInfo.active && expandedInfo.status === Loader.Ready
 
206
                    && !heightAnimation.running) {
 
207
                // stop the current animation
 
208
                ensureVisibleAnimation.running = false;
 
209
 
 
210
                // Get the current position
 
211
                var view = dayDelegate.parent.parent;
 
212
                var pos = view.contentY;
 
213
 
 
214
                // Tell the listview to make the listitem fit
 
215
                view.positionViewAtIndex(index, ListView.Contain);
 
216
 
 
217
                // Animate from the original position to the new position
 
218
                ensureVisibleAnimation.from = pos;
 
219
                ensureVisibleAnimation.to = view.contentY;
 
220
                ensureVisibleAnimation.running = true;
 
221
            } else {
 
222
                restart()
 
223
            }
 
224
        }
 
225
    }
 
226
 
187
227
    Component.onCompleted: {
188
228
        locationPages.collapseOtherDelegates.connect(function(otherIndex) {
189
229
            if (dayDelegate && typeof index !== "undefined" && otherIndex !== index) {