QML 拉式门动画

曾经做过一个拉式门的QML动画,现在项目用不到了,做下记录,以免后面能用到
想用的朋友,可以直接粘贴复制过去,只需要改变组件的state的名称是move还是
back即可,该代码还可以监听动画是否停止,还是启动状态。
 states:[
        State{
            name:"move"
            PropertyChanges{target:rootSetting; x:0; y:0}
            PropertyChanges{target:rootSetting.animItem; x:-(rootSetting.width); y:0}
        },
 
  
        State{
            name:"back"
            PropertyChanges{target:rootSetting; x:(rootSetting.width); y:0}
            PropertyChanges{target:rootSetting.animItem; x:0; y:0}
 
  
            }
     ]
 
  
 
  
 
  
    transitions: Transition{
        PropertyAnimation{
            id:paranim
            properties:"x, y";
            duration: BaseData.animaTime
        }
    }
 
  
    PropertyAnimation{
              id:animation
              duration: BaseData.animaTime;
              onStarted: (rootSetting.state=="move")?(rootSetting.state = "back"):(rootSetting.state = "move")
              onStopped: {
                  if(rootSetting.state == "back") {
                       console.log("back 完成动画嗯.")
                      rootSetting.backLoader()
                  } else {
                      console.log("move =-=完成动画嗯.")
                  }
              }
          }

你可能感兴趣的:(QML)