Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
How to make text scroll within PowerApps - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2019-01-01

In this tutorial, we will see how to use a timer control along with a touch of maths to scroll a text message across the screen. It’s a very simple example but illustrates some basic animation which can be used in many applications.

First, add a simple message to a new PowerApp

Before we start looking at timers we need to add the message which will scroll to the PowerApp.

Step 1: In the PowerApp, add a label that contains your message formatted how you want.

Step 2: Resize the label so that it fits the text exactly.

Step 3: Set the “X” value of the label to a variable, e.g. “vvMessageX”.

Adding the label

The UI will show a red cross error, but that’s okay it just means the variable “vvMessageX” hasn’t been set up yet. We will do that in the timer.

Setting up the timer

Timers in PowerApps allow you to have some code run after a period of time and repeat this forever or until stopped. You get to specify when it starts, the period of time, and what actions it does every time. We will start by just increasing the variable vvMessageX every half second.

Step 1: On the Insert ribbon, from the controls drop down, add a timer to your app. It can be hidden later but for now, it looks like a button.

Step 2: The duration of the timer is in milliseconds, this means 1000 = 1 second. Change the duration to be 500 (half second) and Repeat to be on.

setup the timer

Step 3: A timer control has a property “OnTimerEnd”, this happens at the end of the duration and repeats because we turned on repeat. Change the property to just add “10” to the variable “vvMessageX”. For this, we are going to use “UPDATECONTEXT”, which means “vvMessageX” is a local variable to this screen.

UpdateContext(
    {vvMessageX: vvMessageX + 10}
)

Step 4: Preview the app, click the timer and your message will slowly jump across the screen. We need to speed that up and if you wait long enough your message will vanish off the screen never to be seen again.

Step 5: So to make the message loop around we need to increase until it reaches the screen width and then reset back to the start position. Update the time OnTimerEnd property to include an IF statement inside the JSON statement.

timer formula

You can copy and paste this text:

UpdateContext(
    {
        vvMessageX: If(
            vvMessageX > Screen1.Width,
            -Label1.Width,
            vvMessageX + 10
        )
    }
)

Step 6: Now you need to adjust the duration of the timer and how much you increment the variable to balance the speed and smoothness of the movement. After a little playing around with numbers, I got the duration down to 1ms and increased by 5. 

Finishing touches

At this point, the timer should work when you click on it. Now let’s hide the timer and make it start automatically. To do this, select the timer and change “Autostart” to “true” and “Visible” to “false”.

hide timer and autostart

Preview and test your app and you should see the scrolling text.

Conclusion

Scrolling text, of course, has limited uses but it is always a popular request for those exploring what a PowerApp can do and is a great introduction to using the timer control.

(Visited 6,135 times, 1 visits today)

About the author 

Laura Graham-Brown

SharePoint Trainer, Consultant and Agony Aunt

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.