support for style transitions

This commit is contained in:
Justin R. Miller
2014-05-22 12:46:53 -07:00
parent cbe84299ed
commit aa92e92595
10 changed files with 1182 additions and 108 deletions

View File

@@ -374,17 +374,15 @@ bool Map::getDebug() const {
}
void Map::toggleRaster() {
style.setDefaultTransitionDuration(300);
style.cancelTransitions();
auto it = sources.find("satellite");
if (it != sources.end()) {
Source &satellite_source = *it->second;
if (satellite_source.enabled) {
satellite_source.enabled = false;
auto style_class = style.appliedClasses.find("satellite");
if (style_class != style.appliedClasses.end()) {
style.appliedClasses.erase(style_class);
}
style.appliedClasses.erase("satellite");
} else {
satellite_source.enabled = true;
style.appliedClasses.insert("satellite");
@@ -458,6 +456,12 @@ void Map::prepare() {
style.cascade(state.getNormalizedZoom());
}
animationTime = util::now();
if (style.needsTransition()) {
style.updateTransitions(animationTime);
update();
}
// Allow the sprite atlas to potentially pull new sprite images if needed.
if (style.sprite && style.sprite->isLoaded()) {
spriteAtlas.update(*style.sprite);