Skip to content

Instantly share code, notes, and snippets.

@kovrov
Last active March 23, 2018 22:52
Show Gist options
  • Save kovrov/ddbfd0c06bd20e1068b1 to your computer and use it in GitHub Desktop.
Save kovrov/ddbfd0c06bd20e1068b1 to your computer and use it in GitHub Desktop.
Parallax in a ListView Item
import QtQuick 2.4
ListView {
id: list
width: 800
height: 600
orientation: Qt.Horizontal
model: 5
snapMode: ListView.SnapOneItem
delegate: Rectangle {
id: delegate
width: list.width
height: list.height
color: index % 2 ? "#abc" : "#def"
Rectangle {
transform: Translate { x: (list.contentX - delegate.x) * .1 }
x: 250; y: 180
width: 300; height: 150
color: "#a98"
}
Rectangle {
width: 100; height: 100
anchors.centerIn: parent
color: "#546"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment