MarqueeText.qml
changeset 32 1c2a7f563019
parent 30 c0f274a21d33
child 33 cf5eba52cb1d
     1.1 --- a/MarqueeText.qml	Tue Jun 03 18:35:43 2014 +0200
     1.2 +++ b/MarqueeText.qml	Wed Jun 04 08:12:37 2014 +0200
     1.3 @@ -35,28 +35,31 @@
     1.4          //Reset to zero and restart onStopped so that we keep looping
     1.5          //onStopped: {scrollingText.x=0;running=true;}
     1.6  
     1.7 +        property int lengthInPixels:scrollingText.width-separatorText.width-scrollingText.x;
     1.8 +        property int durationInMs:(animation.lengthInPixels)*1000/pixelsPerSeconds;
     1.9 +
    1.10          NumberAnimation {
    1.11              target: scrollingText;
    1.12              properties: "x"
    1.13              from: scrollingText.x;
    1.14 -            to: scrollingText.x-scrollingText.width-separatorText.width;
    1.15 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.16 +            to: scrollingText.x-animation.lengthInPixels;
    1.17 +            duration:animation.durationInMs
    1.18          }
    1.19  
    1.20          NumberAnimation {
    1.21              target: separatorText;
    1.22              properties: "x"
    1.23              from: separatorText.x;
    1.24 -            to: separatorText.x-scrollingText.width-separatorText.width;
    1.25 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.26 +            to: separatorText.x-animation.lengthInPixels;
    1.27 +            duration: animation.durationInMs
    1.28          }
    1.29  
    1.30          NumberAnimation {
    1.31              target: followingText;
    1.32              properties: "x"
    1.33              from: followingText.x;
    1.34 -            to: followingText.x-scrollingText.width-separatorText.width;
    1.35 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.36 +            to: followingText.x-animation.lengthInPixels;
    1.37 +            duration: animation.durationInMs
    1.38          }
    1.39  
    1.40      }
    1.41 @@ -65,8 +68,22 @@
    1.42      MouseArea {
    1.43          id:mouseArea
    1.44          anchors.fill: parent
    1.45 -        onClicked: {
    1.46 -            animation.running=!animation.running;
    1.47 +        onClicked: {animation.running=!animation.running;
    1.48 +            /*
    1.49 +            if (!animation.running) {
    1.50 +                animation.start();
    1.51 +                return;
    1.52 +            }
    1.53 +            if (animation.paused)
    1.54 +            {
    1.55 +                console.log("resume")
    1.56 +                animation.resume;
    1.57 +            }
    1.58 +            else
    1.59 +            {
    1.60 +                console.log("pause")
    1.61 +                animation.pause;
    1.62 +            }*/
    1.63          }
    1.64      }
    1.65  }