cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Stutting in Animations

Hi all,

 

So I've been trying to implement an animation timer to expand and contract a box, rather than just having it pop in and out of existence. However, with any guides I find, none talk about the stutter effect when you press the button to expand or contract it.

For example, on expanding, the box will appear at full size for a moment, disappear, then begin the animation of expanding. Is this a problem other people have experienced? It's making me feel really reluctant to use animations in my final app.

I've included three pages where people explain their methods and provide sample apps, but they all have the same issue with that stutting effect. Is there someway around this?

 

https://powerapps.microsoft.com/en-us/blog/ux-patterns-expander-control-with-expand-collapse-animati...

 

https://8bitclassroom.com/2018/02/21/powerapps-remix-expand-and-collapse-ui/

 

https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/Vertical-menu-with-expand-and-collapse-...

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Stutting in Animations

Hi @EpicTriffid ,

 

First, let's assume timer duration is set to 500ms, and target height of rectangle is 500 to keep it simple.  We also use a value of true for menuDirection when it's opening, false when it's closing.  By default it starts off false.

Button Onselect:

UpdateContext({animatonStart: true, menuDirection: !menuDirection})

Timer;

OnTimerEnd: UpdateContext({animationStart: false})
Start: animationStart

Duration: 500

 

Rectangle Height:

If(menuDirection, Timer.Value, 500-Timer.Value)

So here's where the stutter comes in.  If you're using the Timer.Value as the derivitive value for your menu height, then the reason you get the stutter is the end state of the Timer and how it resets.  Certainly, this was the case for me, so I'm guessing it's the same for you.

The timer always runs in one direction - from 0 to 500. 

At the end of its cycle, it's sitting at 500.  When the cycle starts again, even though it resets - it resets from 500, meaning your rectangle starts at 500, then jumps to 0 as the timer restarts - hence the stutter.

To avoid this, we need to do two things;

  • Reset the timer automatically after a cycle.
  • Record the state of the rectangle (open or closed) and specify the open or closed height, using that as our base instead of the Timer.Value for the height

Timer;

OnTimerEnd:

UpdateContext({runAnimation: false});
Reset(Timer);
If(menuDirection, 
    UpdateContext({menuState: 500}), 
    UpdateContext({menuState: 0}))

Start: animationStart

Duration: 500

Rectangle Height:

If(menuDirection, menuState+Timer.Value, menuState-Timer.Value)

This cleared it up for me 🙂

Hope this helps,

RT

View solution in original post

7 REPLIES 7
Highlighted
Microsoft
Microsoft

Re: Stutting in Animations

Hi @EpicTriffid ,

 

First, let's assume timer duration is set to 500ms, and target height of rectangle is 500 to keep it simple.  We also use a value of true for menuDirection when it's opening, false when it's closing.  By default it starts off false.

Button Onselect:

UpdateContext({animatonStart: true, menuDirection: !menuDirection})

Timer;

OnTimerEnd: UpdateContext({animationStart: false})
Start: animationStart

Duration: 500

 

Rectangle Height:

If(menuDirection, Timer.Value, 500-Timer.Value)

So here's where the stutter comes in.  If you're using the Timer.Value as the derivitive value for your menu height, then the reason you get the stutter is the end state of the Timer and how it resets.  Certainly, this was the case for me, so I'm guessing it's the same for you.

The timer always runs in one direction - from 0 to 500. 

At the end of its cycle, it's sitting at 500.  When the cycle starts again, even though it resets - it resets from 500, meaning your rectangle starts at 500, then jumps to 0 as the timer restarts - hence the stutter.

To avoid this, we need to do two things;

  • Reset the timer automatically after a cycle.
  • Record the state of the rectangle (open or closed) and specify the open or closed height, using that as our base instead of the Timer.Value for the height

Timer;

OnTimerEnd:

UpdateContext({runAnimation: false});
Reset(Timer);
If(menuDirection, 
    UpdateContext({menuState: 500}), 
    UpdateContext({menuState: 0}))

Start: animationStart

Duration: 500

Rectangle Height:

If(menuDirection, menuState+Timer.Value, menuState-Timer.Value)

This cleared it up for me 🙂

Hope this helps,

RT

View solution in original post

Highlighted
Community Support
Community Support

Re: Stutting in Animations

Hi @EpicTriffid ,

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned.

 

Please take a try with the following workaround:2.JPG

 

3.JPG

 

4.JPG

 

5.JPG

Set the OnSelect property of the "DownIcon" button to following:

Set(IsExpand, true);Set(IsStart, true)

set the Visible property of the "DownIcon" button to following:

If(IsExpand, false, true)

Set the OnSelect property of the "UpIcon" button to following:

Set(IsExpand, false); Set(IsStart, true)

set the Visible property of the "UpIcon" button to following:

If(IsExpand, true, false)

Add a Timer control, set the Duration property to following:

222

set the OnTimerEnd property to following:

Set(IsStart, false)

set the IsStart property to following:

IsStart

Please check the following GIF screenshot for more details:Test.gif

Please also consider take a try with the attached Sample App as below.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

Re: Stutting in Animations

Thank you @RusselThomas! For the life of me, I couldn't work out the WHY of the problem. Extremely grateful for the explanation

Highlighted
Helper II
Helper II

Re: Stutting in Animations

Hi again @RusselThomas! How would you use this process when trying to integrate easing equations, such as Cos. For example:

 

If(expandCollapse,
95*Cos('ani timer_1'.Value/'ani timer_1'.Duration * Pi()/2),
95*(1-Cos('ani timer_1'.Value/'ani timer_1'.Duration * Pi()/2)))

where 95 would be the max height of the box and expandCollapse is the equivalent of your menuDirection?

Highlighted
Microsoft
Microsoft

Re: Stutting in Animations

Hi @EpicTriffid 

You're way ahead of me there - maths was never my strong suit!

My approach to easing is a lot less elegant, but that's just because I don't have a clue how to construct the formulas you're suggesting - I just specify keyframes in the duration that would correlate in segments to your bezier or spline-related easing path.  Less smooth, but works for my brain 🙂

Assuming the breakdown of path velocity as follows;

0-10% = "slow"

10%-80% = "fast"

80%-100% = "slow"

I'd base my height changes as a factor of where the timer is in it's journey.

Using your formula's though would be much more elegant, and smoother as it adjusts for every single tick - even better if we could build in some easing functions in PA that correlate to some of the more popular behaviours (https://easings.net/en).

Sorry I can't help, but I'll definitely watch this post to see what you come up with 🙂  Perhaps you can come up with a nice 'easing calculator' component to share!

 

Good luck!

RT

Highlighted
Helper II
Helper II

Re: Stutting in Animations

Do you have any thoughts on how to save the state of the box at its various points like it your previous solution so that I can avoid the stuttering? I can use my expandCollapse variable the get the movement to work, using the easing equations, but it's still stuttering. I would assume because, like you said, the timer is resetting to 0?

Highlighted
Microsoft
Microsoft

Re: Stutting in Animations

Hi @EpicTriffid ,

Not sure if I'm understanding you correctly, but my savestates were done at the end of the timer duration - i.e. OnTimerEnd property, when completely open or completely closed.

There I set the fully open and fully closed height values depending on the value of the direction, so in your case I'm guessing this would equate to;

 

OnTimerEnd:

UpdateContext({runAnimation: false});
Reset(Timer);
If(expandCollapse, 
    UpdateContext({menuState: 95}), 
    UpdateContext({menuState: 0}))

and the Height property of the box would be ;

If(expandCollapse,
menuState + 95*Cos('ani timer_1'.Value/'ani timer_1'.Duration * Pi()/2),
menuState - 95*(1-Cos('ani timer_1'.Value/'ani timer_1'.Duration * Pi()/2)))

 ...just guessing though, hope this helps

 

RT

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,675)