Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Stutting in Animations

(0) ShareShare
ReportReport
Posted on by 338

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-animation/

 

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-feature/ba-p/90220

Categories:
  • RusselThomas Profile Picture
    RusselThomas 4,012 on at
    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

  • EpicTriffid Profile Picture
    EpicTriffid 338 on at
    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?

  • RusselThomas Profile Picture
    RusselThomas 4,012 on at
    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

  • EpicTriffid Profile Picture
    EpicTriffid 338 on at
    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?

  • EpicTriffid Profile Picture
    EpicTriffid 338 on at
    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

  • v-xida-msft Profile Picture
    v-xida-msft on at
    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,

  • Verified answer
    RusselThomas Profile Picture
    RusselThomas 4,012 on at
    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard