diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp index 5d9e79fecce..09b54c0ae35 100644 --- a/src/mbgl/map/map_data.hpp +++ b/src/mbgl/map/map_data.hpp @@ -24,7 +24,7 @@ class MapData { : mode(mode_) , pixelRatio(pixelRatio_) , animationTime(Duration::zero()) - , defaultFadeDuration(std::chrono::milliseconds(300)) + , defaultFadeDuration(mode_ == MapMode::Continuous ? std::chrono::milliseconds(300) : Duration::zero()) , defaultTransitionDuration(Duration::zero()) , defaultTransitionDelay(Duration::zero()) { assert(pixelRatio > 0); @@ -71,9 +71,13 @@ class MapData { inline TimePoint getAnimationTime() const { // We're casting the TimePoint to and from a Duration because libstdc++ // has a bug that doesn't allow TimePoints to be atomic. - return TimePoint(animationTime); + return mode == MapMode::Continuous ? TimePoint(animationTime) : Clock::now(); } inline void setAnimationTime(const TimePoint& timePoint) { + if (mode == MapMode::Still) { + return; + } + animationTime = timePoint.time_since_epoch(); }; @@ -82,6 +86,10 @@ class MapData { } inline void setDefaultFadeDuration(const Duration& duration) { + if (mode == MapMode::Still) { + return; + } + defaultFadeDuration = duration; } @@ -90,6 +98,10 @@ class MapData { } inline void setDefaultTransitionDuration(const Duration& duration) { + if (mode == MapMode::Still) { + return; + } + defaultTransitionDuration = duration; } @@ -98,6 +110,10 @@ class MapData { } inline void setDefaultTransitionDelay(const Duration& delay) { + if (mode == MapMode::Still) { + return; + } + defaultTransitionDelay = delay; } diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 1d669383075..fac53066010 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -520,11 +520,11 @@ template<> StyleParser::Result StyleParser::parseProperty(JS PropertyTransition transition { data.getDefaultTransitionDuration(), data.getDefaultTransitionDelay() }; if (value.IsObject()) { bool parsed = false; - if (value.HasMember("duration") && value["duration"].IsNumber()) { + if (value.HasMember("duration") && value["duration"].IsNumber() && data.mode == MapMode::Continuous) { transition.duration = std::chrono::milliseconds(value["duration"].GetUint()); parsed = true; } - if (value.HasMember("delay") && value["delay"].IsNumber()) { + if (value.HasMember("delay") && value["delay"].IsNumber() && data.mode == MapMode::Continuous) { transition.delay = std::chrono::milliseconds(value["delay"].GetUint()); parsed = true; } @@ -594,7 +594,7 @@ template<> StyleParser::Result> StyleParser::parseProperty(JSVal template<> StyleParser::Result>>> StyleParser::parseProperty(JSVal value, const char *property_name, JSVal transition) { Duration duration = data.getDefaultFadeDuration(); - if (transition.HasMember("duration")) { + if (transition.HasMember("duration") && data.mode == MapMode::Continuous) { duration = std::chrono::milliseconds(transition["duration"].GetUint()); } @@ -613,7 +613,7 @@ template<> StyleParser::Result StyleParser::Result>> StyleParser::parseProperty(JSVal value, const char *property_name, JSVal transition) { Duration duration = data.getDefaultFadeDuration(); - if (transition.HasMember("duration")) { + if (transition.HasMember("duration") && data.mode == MapMode::Continuous) { duration = std::chrono::milliseconds(transition["duration"].GetUint()); }