Scroll animation
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.
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.
Hello
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!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.