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

Hack transition from undefined fill-outline-color #4020

Merged
merged 6 commits into from
Jan 26, 2017
Merged

Hack transition from undefined fill-outline-color #4020

merged 6 commits into from
Jan 26, 2017

Conversation

anandthakker
Copy link
Contributor

@anandthakker anandthakker commented Jan 19, 2017

Closes #3657

Using "option 1" described here

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

// https://github.com/mapbox/mapbox-gl-js/issues/3657
const transition = this._paintTransitions['fill-outline-color'];
if (!transition.instant()) {
const source = transition.oldTransition._calculateTargetValue(globalProperties, featureProperties);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unfortunate use of private method _calculateTargetValue, but my feeling is that it's (slightly) less bad than the only other non-invasive alternative that I could see, which would be to hack interpolate.color so that it can handle undefined values for from. I prefer the hack here because it's more localized, and will be easier to excise when we get rid of fill-outline-color.

@anandthakker anandthakker requested a review from mourner January 19, 2017 23:06
@anandthakker
Copy link
Contributor Author

benchmark master 2793b42 3657 193e124
map-load 101 ms 139 ms
style-load 91 ms 87 ms
buffer 943 ms 954 ms
fps 60 fps 60 fps
frame-duration 4.7 ms, 0% > 16ms 4.6 ms, 0% > 16ms
query-point 0.67 ms 0.79 ms
query-box 59.62 ms 62.67 ms
geojson-setdata-small 6 ms 5 ms
geojson-setdata-large 113 ms 172 ms

@anandthakker
Copy link
Contributor Author

@mourner @lucaswoj ready for 👀

@anandthakker
Copy link
Contributor Author

Transcribing from chat

@anandthakker I agree with you that using _calculateTargetValue feels non-optimal
Do you think it’d be possible to fix the bug by changing the construction of fill-outline-color‘s StyleTransition object?
Another alternative:
tidy up the StyleTransition API and get rid of the underscore

We agreed to go with the second option, but after looking into this (and also, alas, a detour 👇🐰🕳 investigating the first option), I'm now 👎 on removing the underscore. The method we'd have to remove the underscore on, _calculateTargetValue, really is an internal implementation detail of StyleTransition, and I don't think there's any natural/legit part of it to extract into a public method. Doing so feels contrived, which IMO is no better than actually using the underscored method in the first place.

All that said, in 20ea68f i did revise to a slightly cleaner approach by relying on the public--though sorta deep--object hierarchy rather than the private method

StyleTransition --> StyleDeclaration --> value
  +- oldTransition: StyleTransition // forms a chain of ongoing transitions
  +- declaration: StyleDeclaration

StyleDeclaration
  +- value: ... // the declared value, which might be undefined

cc @lucaswoj @mourner

Copy link
Contributor

@lucaswoj lucaswoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@anandthakker anandthakker merged commit 59e6b40 into master Jan 26, 2017
@anandthakker anandthakker deleted the 3657 branch January 26, 2017 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants