While here, do not interpolate style properties that are not transitionable. The previous behavior was to switch from old to new value halfway through the transition; now the new value is used immediately, as in JS.
27 lines
579 B
C++
27 lines
579 B
C++
#include <mbgl/util/transition.hpp>
|
|
#include <mbgl/util/unitbezier.hpp>
|
|
#include <mbgl/util/interpolate.hpp>
|
|
#include <mbgl/platform/platform.hpp>
|
|
|
|
namespace mbgl { namespace util {
|
|
|
|
UnitBezier ease(0, 0, 0.25, 1);
|
|
|
|
transition::~transition() {}
|
|
|
|
template <typename T>
|
|
transition::state ease_transition<T>::update(timestamp now) const {
|
|
float t = progress(now);
|
|
if (t >= 1) {
|
|
value = to;
|
|
return complete;
|
|
} else {
|
|
value = interpolate(from, to, ease.solve(t, 0.001));
|
|
return running;
|
|
}
|
|
}
|
|
|
|
template class ease_transition<double>;
|
|
|
|
}}
|