[core] - allow moveBy to use AnimationOptions
[android] - update jni bindings for moveBy with an interpolator
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/util/size.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/map/camera.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
void flyTo(const CameraOptions&, const AnimationOptions&);
|
||||
|
||||
// Position
|
||||
void moveBy(const ScreenCoordinate&, const Duration& = Duration::zero());
|
||||
void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
|
||||
void setLatLng(const LatLng&, optional<ScreenCoordinate>, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, optional<EdgeInsets>, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, const Duration& = Duration::zero());
|
||||
|
||||
@@ -488,7 +488,14 @@ void nativeMoveBy(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl
|
||||
jlong duration) {
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().moveBy({dx, dy}, mbgl::Milliseconds(duration));
|
||||
|
||||
mbgl::AnimationOptions animationOptions;
|
||||
if (duration > 0) {
|
||||
animationOptions.duration.emplace(mbgl::Milliseconds(duration));
|
||||
animationOptions.easing.emplace(mbgl::util::UnitBezier { 0, 0.3, 0.6, 1.0 });
|
||||
}
|
||||
|
||||
nativeMapView->getMap().moveBy({dx, dy}, animationOptions);
|
||||
}
|
||||
|
||||
void nativeSetLatLng(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble latitude, jdouble longitude, jlong duration) {
|
||||
|
||||
@@ -478,9 +478,9 @@ void Map::flyTo(const CameraOptions& camera, const AnimationOptions& animation)
|
||||
|
||||
#pragma mark - Position
|
||||
|
||||
void Map::moveBy(const ScreenCoordinate& point, const Duration& duration) {
|
||||
void Map::moveBy(const ScreenCoordinate& point, const AnimationOptions& animation) {
|
||||
impl->cameraMutated = true;
|
||||
impl->transform.moveBy(point, duration);
|
||||
impl->transform.moveBy(point, animation);
|
||||
impl->onUpdate(Update::Repaint);
|
||||
}
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
|
||||
|
||||
#pragma mark - Position
|
||||
|
||||
void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration) {
|
||||
void Transform::moveBy(const ScreenCoordinate& offset, const AnimationOptions& animation) {
|
||||
ScreenCoordinate centerOffset = {
|
||||
offset.x,
|
||||
-offset.y,
|
||||
@@ -331,7 +331,7 @@ void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration)
|
||||
|
||||
CameraOptions camera;
|
||||
camera.center = state.screenCoordinateToLatLng(centerPoint);
|
||||
easeTo(camera, duration);
|
||||
easeTo(camera, animation);
|
||||
}
|
||||
|
||||
void Transform::setLatLng(const LatLng& latLng, const Duration& duration) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
/** Pans the map by the given amount.
|
||||
@param offset The distance to pan the map by, measured in pixels from
|
||||
top to bottom and from left to right. */
|
||||
void moveBy(const ScreenCoordinate& offset, const Duration& = Duration::zero());
|
||||
void moveBy(const ScreenCoordinate& offset, const AnimationOptions& = {});
|
||||
void setLatLng(const LatLng&, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, optional<EdgeInsets>, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, optional<ScreenCoordinate>, const Duration& = Duration::zero());
|
||||
|
||||
Reference in New Issue
Block a user