2024-01-16 03:28 AM
Does in the TouchGFX is scrollable container animation? I use doScroll() function but it would be nicer if it scrolls automatically with animation or smoothly.
Solved! Go to Solution.
2024-01-26 02:22 AM
Hello @heyo ,
Scrollable container does not provide a function for animation directly, however, you can use Easing Equations to calculate the deltas to have a smoother scroll. You can use a method similar to this:
#include "touchgfx/EasingEquations.hpp" //To have Easing Equations
//If new item is inserted, set the animationIsRunning to true
void Screen1View::handleTickEvent()
{
if (animationIsRunning)
{
scrollWithAnimation();
}
}
void Screen1View::scrollWithAnimation()
{
const int duration = 50;
if (animationCounter <= duration)
{
int16_t delta = EasingEquations::linearEaseIn(animationCounter, 0, /* The final scroll value */, duration);
scrollableContainer1.doScroll(0, delta); //If scrolling vertically
scrollableContainer1.invalidate();
animCounter++;
}
else
{
animationCounter = 0;
animationIsRunning = false;
}
}
I hope this helps you!
2024-01-26 02:22 AM
Hello @heyo ,
Scrollable container does not provide a function for animation directly, however, you can use Easing Equations to calculate the deltas to have a smoother scroll. You can use a method similar to this:
#include "touchgfx/EasingEquations.hpp" //To have Easing Equations
//If new item is inserted, set the animationIsRunning to true
void Screen1View::handleTickEvent()
{
if (animationIsRunning)
{
scrollWithAnimation();
}
}
void Screen1View::scrollWithAnimation()
{
const int duration = 50;
if (animationCounter <= duration)
{
int16_t delta = EasingEquations::linearEaseIn(animationCounter, 0, /* The final scroll value */, duration);
scrollableContainer1.doScroll(0, delta); //If scrolling vertically
scrollableContainer1.invalidate();
animCounter++;
}
else
{
animationCounter = 0;
animationIsRunning = false;
}
}
I hope this helps you!
2024-02-02 03:40 AM
Sorry but it's working like doScroll() function..
2024-02-02 04:46 AM
If you press insert new item rapidly, there might be a chance that the animation is not ended yet and the new item is added quickly. You have to allow the animation steps to end before adding a new item