Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transitions from property default values #2769

Closed
jfirebaugh opened this issue Jun 20, 2016 · 3 comments · Fixed by #5682
Closed

Fix transitions from property default values #2769

jfirebaugh opened this issue Jun 20, 2016 · 3 comments · Fixed by #5682

Comments

@jfirebaugh
Copy link
Contributor

Noticed while working on #2762.

map.setPaintProperty("circle", "circle-color", "red") when called on this layer will interpolate black to red correctly:

                {
                    "id": "circle",
                    "type": "circle",
                    "source": "geojson",
                    "paint": {
                        "circle-color": "black"
                    }
                }

However, with this layer it'll just jump from black to red without a transition:

                {
                    "id": "circle",
                    "type": "circle",
                    "source": "geojson",
                    "paint": {}
                }

The expected behavior is for both to have an interpolated transition.

@lucaswoj lucaswoj changed the title transitions from property default values don't work correctly Fix transitions from property default values Jul 29, 2016
@stepankuzmin
Copy link
Contributor

stepankuzmin commented Jan 11, 2017

Hi! I've done a little research and found, that StyleLayer#_paintDeclarations is empty for layers with default paint properties, while layers with specified paint properties have _paintDeclarations.

I've tried to set paint declaration to default after https://github.com/mapbox/mapbox-gl-js/blob/master/js/style/style_layer.js#L111 like this:

this._paintDeclarations[klass || ''][name] = new StyleDeclaration(this._paintSpecifications[name]);

but it does not affect transition. So am I missing something? Should we explicitly define default paint properties in StyleLayer constructor? (something like this)

for (paintName in this._paintSpecifications) {
    this.setPaintProperty(paintName, this._paintSpecifications[paintName].default);
}

@mourner
Copy link
Member

mourner commented Jan 12, 2017

@stepankuzmin I would suggest exploring style_transition.js for why it doesn't transition from a default property. There's an early bailout there somewhere probably.

@stepankuzmin
Copy link
Contributor

It seems that there is no transition from defaults because there is no oldTransition to transition from. oldTransition for StyleLayer is set in _applyPaintDeclaration, which is called from updatePaintTransitions if StyleLayer._paintDeclarations is not empty. For layer with default paint properties, there is no _paintDeclarations, so there is no oldTransition also.

Defining default paint properties in StyleLayer constructor solves the problem, but I am not sure about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants