Created
July 30, 2014 14:05
-
-
Save dahnielson/1284c7badff0159b1056 to your computer and use it in GitHub Desktop.
QML Recipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.2 | |
Flickable { | |
id: flickable | |
anchors.fill: parent | |
contentWidth: flickable.width * 2 | |
contentHeight: 0 | |
boundsBehavior: Flickable.StopAtBounds | |
flickableDirection: Flickable.HorizontalFlick | |
onMovementEnded: snapPage(this) | |
Behavior on contentX { SmoothedAnimation { velocity: 1000 } } | |
function snapPage(self) { | |
if (self.visibleArea.xPosition < 0.25) | |
self.contentX = 0; | |
else if (self.visibleArea.xPosition > 0.25) | |
self.contentX = self.width; | |
} | |
// First pane | |
Rectangle { | |
x: 0 | |
y: 0 | |
width: flickable.width | |
height: flickable.height | |
color: "green" | |
} | |
// Second pane | |
Rectangle { | |
x: flickable.width | |
y: 0 | |
width: flickable.width | |
height: flickable.height | |
color: "yellow" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment