MCPcopy Create free account
hub / github.com/comaps/comaps / CreateKineticAnimation

Method CreateKineticAnimation

libs/drape_frontend/kinetic_scroller.cpp:181–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181drape_ptr<Animation> KineticScroller::CreateKineticAnimation(ScreenBase const & modelView)
182{
183 auto const [dir, velocity] = GetDirectionAndVelocity(modelView);
184 // Cancel current animation in any case.
185 Cancel();
186 if (velocity < 1E-6)
187 return {};
188
189 // Before we start animation we have to convert velocity vector from pixel space to mercator space.
190 m2::PointD const center = modelView.GlobalRect().GlobalCenter();
191 double const offset = (modelView.PtoG(modelView.GtoP(center) + dir * velocity) - center).Length();
192 double const glbLength = kKineticAcceleration * offset;
193 m2::PointD const glbDirection = dir * glbLength;
194 m2::PointD const targetCenter = center + glbDirection;
195 if (!df::GetWorldRect().IsPointInside(targetCenter))
196 return {};
197
198 return make_unique_dp<KineticScrollAnimation>(center, glbDirection, kKineticDuration);
199}
200} // namespace df

Callers 1

EndDragMethod · 0.80

Calls 6

GetWorldRectFunction · 0.85
GlobalCenterMethod · 0.80
LengthMethod · 0.45
PtoGMethod · 0.45
GtoPMethod · 0.45
IsPointInsideMethod · 0.45

Tested by

no test coverage detected