Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57242

SwipeDelegate::position value jumps abruptly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.0 Beta 1
    • 5.7.0
    • Quick: Controls 2
    • None
    • d49ab00f2b9c99da48d9ddef2b0627a86d54b95e

    Description

      It should be possible to apply scale/opacity etc. animations on the left/right/behind items based on the position of the swipe. The problem is that when a swipe is released or when swipe.close() is called, even though SwipeDelegates own visuals animate, anything bound to SwipeDelegate::position doesn't. SwipeDelegate should run a transition on the position to make things animate as appropriate.

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Controls.Material 2.0
      
      ApplicationWindow {
          width: 300
          height: 400
          visible: true
      
          ListView {
              model: 10
              anchors.fill: parent
      
              delegate: SwipeDelegate {
                  id: delegate
                  text: index
                  width: parent.width
      
                  swipe.left: Rectangle {
                      width: parent.width
                      height: parent.height
                      color: Material.color(Material.Green, SwipeDelegate.pressed ? Material.Shade700 : Material.Shade500)
      
                      Label {
                          text: "Left"
                          color: "white"
                          anchors.margins: 10
                          anchors.left: parent.left
                          anchors.verticalCenter: parent.verticalCenter
                          scale: delegate.swipe.position // <==
                      }
      
                      SwipeDelegate.onClicked: delegate.swipe.close()
                  }
      
                  swipe.right: Rectangle {
                      width: parent.width
                      height: parent.height
                      anchors.right: parent.right
                      color: Material.color(Material.Red, SwipeDelegate.pressed ? Material.Shade700 : Material.Shade500)
      
                      Label {
                          text: "Right"
                          color: "white"
                          anchors.margins: 10
                          anchors.right: parent.right
                          anchors.verticalCenter: parent.verticalCenter
                          scale: -delegate.swipe.position // <==
                      }
      
                      SwipeDelegate.onClicked: delegate.swipe.close()
                  }
              }
          }
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-57242
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            jpnurmi J-P Nurmi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes