Skip to content

Instantly share code, notes, and snippets.

@dahnielson
Created July 30, 2014 14:05
Show Gist options
  • Save dahnielson/1284c7badff0159b1056 to your computer and use it in GitHub Desktop.
Save dahnielson/1284c7badff0159b1056 to your computer and use it in GitHub Desktop.
QML Recipes
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