~aacid/unity8/card_optimizations

« back to all changes in this revision

Viewing changes to qml/Components/Carousel.qml

  • Committer: Albert Astals
  • Date: 2014-04-17 11:11:27 UTC
  • mfrom: (796.6.43 unity8)
  • Revision ID: albert.astals@canonical.com-20140417111127-jns8uvil2t6oen23
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
       The scaling of the items is controlled by the variable continuousIndex, described below. */
76
76
    ListView {
77
77
        id: listView
 
78
        objectName: "listView"
78
79
 
79
80
        property int highlightIndex: -1
80
81
        property real minimumTileWidth: 0
148
149
        maximumFlickVelocity: Math.max(2500 * Math.pow(realWidth / referenceWidth, 1.5), 2500) // 2500 is platform default
149
150
        orientation: ListView.Horizontal
150
151
 
 
152
        function getXFromContinuousIndex(index) {
 
153
            return CarouselJS.getXFromContinuousIndex(index,
 
154
                                                       realWidth,
 
155
                                                       footerItem.x,
 
156
                                                       tileWidth,
 
157
                                                       gapToMiddlePhase,
 
158
                                                       gapToEndPhase,
 
159
                                                       carousel.drawBuffer)
 
160
        }
 
161
 
151
162
        function itemClicked(index, delegateItem) {
152
163
            listView.currentIndex = index
153
 
            var x = CarouselJS.getXFromContinuousIndex(index,
154
 
                                                       realWidth,
155
 
                                                       realContentWidth,
156
 
                                                       tileWidth,
157
 
                                                       gapToMiddlePhase,
158
 
                                                       gapToEndPhase,
159
 
                                                       carousel.drawBuffer)
 
164
            var x = getXFromContinuousIndex(index);
160
165
 
161
166
            if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
162
167
                /* We're clicking the selected item and
174
179
        }
175
180
 
176
181
        function itemPressAndHold(index, delegateItem) {
177
 
            var x = CarouselJS.getXFromContinuousIndex(index,
178
 
                                                       realWidth,
179
 
                                                       realContentWidth,
180
 
                                                       tileWidth,
181
 
                                                       gapToMiddlePhase,
182
 
                                                       gapToEndPhase,
183
 
                                                       carousel.drawBuffer);
 
182
            var x = getXFromContinuousIndex(index);
184
183
 
185
184
            if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
186
185
                /* We're pressAndHold the selected item and
209
208
            newContentX = disabledNewContentX
210
209
        }
211
210
        onMovementEnded: {
212
 
            if (realContentX > 0 && realContentX < realContentWidth - realWidth)
 
211
            if (realContentX > 0)
213
212
                stepAnimation.start()
214
213
        }
215
214
 
216
215
        SmoothedAnimation {
217
216
            id: stepAnimation
 
217
            objectName: "stepAnimation"
218
218
 
219
219
            target: listView
220
220
            property: "contentX"
221
 
            to: CarouselJS.getXFromContinuousIndex(listView.selectedIndex,
222
 
                                                   listView.realWidth,
223
 
                                                   listView.realContentWidth,
224
 
                                                   listView.tileWidth,
225
 
                                                   listView.gapToMiddlePhase,
226
 
                                                   listView.gapToEndPhase,
227
 
                                                   carousel.drawBuffer)
 
221
            to: listView.getXFromContinuousIndex(listView.selectedIndex)
228
222
            duration: 450
229
223
            velocity: 200
230
224
            easing.type: Easing.InOutQuad